Monitor.Enter and Monitor.Exit in different threads

前端 未结 3 394
鱼传尺愫
鱼传尺愫 2020-12-11 16:21

Monitor.Enter and Monitor.Exit are designed to be called from the same thread. But, what if I need to release a lock in a different thread than acq

3条回答
  •  天命终不由人
    2020-12-11 16:52

    Try using a ManualResetEvent, it's used to block thead(s) until some external event has been triggered. MSDN Doc:

    http://msdn.microsoft.com/en-us/library/system.threading.manualresetevent.aspx

提交回复
热议问题