.NET threading: how to wait for another thread to complete some task
Suppose I have a void SomeMethod (Action callback) method This method does some work on a background thread and then calls a callback. The question is how to block the current thread before calling the callback?
There is an example
bool finished = false;
SomeMethod(delegate{
finished = true;
});
while(!finished)
Thread.Sleep();
But I'm sure there must be a better way
+2
a source to share