开发者

WindowsFormsSynchronizationContext locks for a long time on Post

I have been looking at the delay/lock of posting asynchronously to a WindowsFormsSynchronizationContext and have discovered that this uses the Control.MarshaledInvoke method, which has two locks inside! Since, the SynchronizationContext uses a global Control (the Application.MarshalingControl) one is effectively hitting a single lock and, thus, a 开发者_运维技巧throughput limit when using this.

Something, we have witnessed several times can result in very long delays e.g. when connecting to a machine through Remote Desktop it appears the controls are locked for a long time.

My question is, has anyone encountered this issue? And any suggestion for a solution?

I am contemplating putting the actual Post on the thread pool using Task.Run... but this would give an additional overhead. Our main concern here is the the thread posting asynchronously should not be locked for a long time > 1 ms, so I guess putting the action on a task would work, but this also introduces GC pressure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜