SynchronizationContext.IsWaitNotificationRequired 的用途是什么?

发布于 2024-12-22 00:15:14 字数 843 浏览 3 评论 0 原文

SynchronizationContext 有一个属性称为 IsWaitNotificationRequired。其目的是,文档说:

确定是否需要等待通知。

如果需要等待通知则为true;否则为假。

天哪,这澄清了事情。

这个“等待通知”到底是什么,何时/为什么需要/不需要? IsWaitNotificationRequired 是否类似于 Control.InvokeRequired,或者这是不同的东西?

SynchronizationContext has a property called IsWaitNotificationRequired. Of its purpose, the docs have this to say:

Determines if wait notification is required.

true if wait notification is required; otherwise, false.

Gosh, that clarifies things.

What exactly is this "wait notification", and when / why would it be required / not required? Is IsWaitNotificationRequired something along the lines of Control.InvokeRequired, or is this something different?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魔法少女 2024-12-29 00:15:14

这是针对允许连接到 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 of SynchronizationContext and if it does your overridden implementation of the Wait method gets called.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文