SynchronizationContext.IsWaitNotificationRequired 的用途是什么?
SynchronizationContext
有一个属性称为 IsWaitNotificationRequired
。其目的是,文档说:
确定是否需要等待通知。
如果需要等待通知则为true;否则为假。
天哪,这澄清了事情。
这个“等待通知”到底是什么,何时/为什么需要/不需要? IsWaitNotificationRequired
是否类似于 Control.InvokeRequired
,或者这是不同的东西?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是针对允许连接到 CLR 同步等待例程的基础结构。此博客文章解释了其工作原理:https://web.archive.org/web/20080503180352/http://www.bluebytesoftware.com/blog/2008/02/27/HookingCLRBlockingCallsWithSynchronizationContext.aspx
此属性将始终返回
false
如果此行为尚未在SynchronizationContext
的子类中被专门重写,并且如果确实如此您重写的Wait
方法的实现将被调用。This is for infrastructure that allows hooking up into CLR synchronisation wait routine. This blog post explains how this works: https://web.archive.org/web/20080503180352/http://www.bluebytesoftware.com/blog/2008/02/27/HookingCLRBlockingCallsWithSynchronizationContext.aspx
This property will always return
false
if this behaviour has not been specifically overridden in a subclass ofSynchronizationContext
and if it does your overridden implementation of theWait
method gets called.