Why did entering a lock on a UI thread trigger an OnPaint event?

后端 未结 3 2047
小鲜肉
小鲜肉 2020-12-09 12:40

I came across something I simply don\'t understand. In my application I have several threads all adding (and removing) items to a shared collection (using a shared lock). Th

3条回答
  •  北海茫月
    2020-12-09 12:51

    Good question!

    All waits in .NET are "alertable." This means that if a wait blocks, Windows can run "Asynchronous Procedure Calls" on top of the waiting stack. This can include processing some windows messages. I haven't tried WM_PAINT specifically, but from your observations, I guess it is included.

    Some MSDN links:

    Wait Functions

    Asynchronous Procedure Calls

    Joe Duffy's book "Concurrent Programming on Windows" also covers this.

提交回复
热议问题