.NET Threading : How to wait for other thread to finish some task
- by Alex Ilyin
Assume I have method
void SomeMethod(Action callback)
This method does some work in background thread and then invokes callback. The question is - how to block current thread until callback is called ?
There is an example
bool finished = false;
SomeMethod(delegate{
finished = true;
});
while(!finished)
Thread.Sleep();
But I'm sure there should be better way