其中阻塞线程操作在.NET中发生堵塞时将处理COM消息? [英] Which blocking threading operations in .NET will handle COM messages when blocked?

查看:71
本文介绍了其中阻塞线程操作在.NET中发生堵塞时将处理COM消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在创建一个新的STA线程来承载一个STA COM组件,它是一个线程泵相关的COM Windows消息的责任。从我已经能够收集,某些内置.NET线程原语,如锁(Monitor.Enter)会为你做这个等待的对象被另一个线程释放。使得.NET泵COM消息,你是我见过的另一种方法是使用。加入()。

When creating a new STA thread to host an STA COM component, it is the responsibility of that thread to pump Windows messages related to COM. From what I've been able to gather, certain built in .NET threading primitives such as lock (Monitor.Enter) will do this for you while waiting for the object to be released by another thread. Another way of making .NET pump COM messages for you that I've seen is to use .Join().

我在哪里可以找到建于线程原语此行为的完整列表?会等待一个WaitHandle的支持呢?怎么样了WaitAny(),或在.NET 4的新并发集合?我无法找到这个任何的具体方法的文档。

Where can I find a complete list of built in threading primitives with this behaviour? Would waiting on a WaitHandle support this? What about WaitAny(), or the new concurrent collections in .NET 4? I'm unable to find this in the documentation for any of the specific methods.

推荐答案

这可以从SSCLI20源逆向工程一些,尽管它是过时了。核心CLR函数实现MsgWaitForMultipleHandles是DoAppropriateWait。从我所看到的,它是用的AutoResetEvent,ManualResetEvent的和信号,但的不是的用互斥。一个怪癖,就是WaitHandle.WaitAny是好的,从一个STA线程,但为WaitAll()生成异常。是啊,这是不记录任何地方其他然后一些提示克里斯Brumme的博客。你不能假设,从我发现太多,测试这是肯定的。

This can be reverse-engineered somewhat from the SSCLI20 source, albeit that it is dated. The core CLR function that implements MsgWaitForMultipleHandles is DoAppropriateWait. From what I see, it is used by AutoResetEvent, ManualResetEvent and Semaphore but not by Mutex. One quirk is that WaitHandle.WaitAny is okay from an STA thread but WaitAll() generates an exception. Yeah, this isn't documented anywhere other then a few hints in Chris Brumme's blog. You can't assume too much from what I found, test this to be sure.

这篇关于其中阻塞线程操作在.NET中发生堵塞时将处理COM消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆