How is this possible: OnPaint processed while in WaitOne

后端 未结 2 1088
猫巷女王i
猫巷女王i 2020-11-30 08:01

I have a ManualResetEvent. At one point, I wait on that event using WaitOne. To my amazement, I received an OnPaint event while in the

2条回答
  •  孤街浪徒
    2020-11-30 08:10

    I have seen this behavior too for the lock() statement. Apparently the .net framework Thread classes starts a message loop when waiting for a lock on the UI thread. This just explains what is happening. The reasoning could be to prevent deadlocks when working with legacy STA COM objects. I am not aware of a way to prevent this.

提交回复
热议问题