In .NET you can use lock state as in
object oLock = new object(); lock(oLock){
What you are looking for is mutexes or events. You can use the ManualResetEvent class and make the thread wait through
ManualResetEvent mre = new ManualResetEvent(false); ... mre.WaitOne();
Otherwise, another thread calls
mre.Set();
to signal another thread that it can continue.
Take a look here .
source share