问题描述
MSDN文档表明,有可能使用ExitContext标志的其他方式。请参见 WaitHandle.WaitOne()其他什么方法是有进入非默认情况下使用ContextBoundObject继承的类之外? (在我的应用程序无法使用ContextBoundObject)
MSDN documentation suggests that there may be other ways of using ExitContext flag. See WaitHandle.WaitOne() What other ways are there to enter a non-default context outside of using a ContextBoundObject inherited class? (I can't use ContextBoundObject in my application)
推荐答案
线索是这句话。
即使您正在执行 方法一类不获得 自ContextBoundObject,如String, 你可以在非默认情况下,如果 一个ContextBoundObject是在栈 在当前的应用程序域。
因此,基本上,你可以调用的WaitOne
从类中不继承 ContextBoundObject
也不会有任何preconceived概念,即 ContextBoundObject
在涉及您的code任何方式,但有问题的线程可能是在非默认情况下,因为地方的方式在通话堆栈的实例方法 ContextBoundObject
类可以运行不为人知你。
So basically you could call WaitOne
from within a class that does not subclass ContextBoundObject
nor would you have any preconceived notion that a ContextBoundObject
was in any way involved with your code and yet the thread in question could be in a nondefault context because somewhere way up in the call stack an instance method of a ContextBoundObject
class could be running unbeknown to you.
这是唯一的例外之外还有进入一个非默认的同步方面没有其他办法。
Outside of that lone exception there are no other ways of entering into a nondefault synchronization context.
有与相关的同步上下文的附加信息穿线pretty的好文章,可找到的。
There is a pretty good article on threading with additional information related to synchronization contexts which can be found here.
这篇关于可以WaitHandle.WaitOne有没有ContextBoundObject类中使用ExitContext标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!