The fact that the program freezes doesn't have anything to do with the out
parameter.
The program freezes because you call Thread.Join()
which basically reads: "block the calling thread until I finish processing".
Because the calling thread is the UI thread, the UI freezes.
There are a number of ways to solve this problem, the most appealing of which is to use the await
keyword (C# 5) but given the dependency on NET 4.5, you may opt to attach a continuation manually instead:
Task.Factory.StartNew(() => tempFunction(index, out Fullname, out Info))
.ContinueWith(r => MessageBox.Show(Fullname + "\n" + Info));
(You are going to need to target .NET 4.0 in order to use the Task
class.)
If you are limited to an earlier version of the framework then the next best solution will likely be to use the BackgroundWorker
component given that you appear to be working with a Windows Forms application.