I’m using C# and Visual Studio 2010. Is this ok or do i need to change it?
public bool SomeFunction(string arg1)
{
bool ok = false;
var firstThread = new Thread(delegate()
{
ok = SomeFunction2(arg1);
});
firstThread.Start();
firstThread.Join();
return ok;
}
I’m not sure how long running the process on the other thread is — but starting the thread and then joining to it confuses me because the join call causes the calling thread to be blocked until the other is finished.
However, if you actually needed the process to run on another thread look up the BackgroundWorker because it will make multi-threading very easy. You attach to events to manage the background thread, progress reporting, cancellation and completed.
Let me know if you need some help but here is a great example of using a background worker.
http://msdn.microsoft.com/en-us/library/cc221403(v=vs.95).aspx