WaitOne()是否等待非托管线程? [英] Does WaitOne() wait unmanaged threads?

查看:52
本文介绍了WaitOne()是否等待非托管线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好-

我正在处理一个奇怪的问题,但不确定该问题是否与该表格有关(我的C#代码已发布)或VB6,但我仍然会在这里询问.

I am working on a bit of a strange problem and I'm not sure if the issue is relivant to this form (issue with my C# code) or VB6, but I will ask here anyway.

我有一个VB6应用,它有一个300毫秒的计时器,该计时器用于轮询串行端口以检查新数据,但是好像更新了(速度更快) )计算机无法正常工作,因此我决定将其切换为使用托管串行端口 目的.我正在使用COM接口和AutomaticResetEvent来强制对托管代码的调用是同步的.

I have a VB6 app the has a 300ms timer which used to poll a serial port to check for new data, but it seems like with newer (faster) computers this isn't working so I decided to switch it to using the managed serial port object.  I am using a COM interface and an AutomaticResetEvent to force the call into the managed code to be syncronous.

我遇到一个问题,即计时器或UI线程(实际上是相同的)是否在AutomaticResetEvent :: WaitOne( )以返回串行端口,另一个变为活动状态.

I am running into an issue where if either the timer or the UI thread (they are actually the same) are waiting on the AutomaticResetEvent::WaitOne() for the serial port to return, the other one becomes active.

我发现了三篇有关此的博客文章,但它们似乎都过时了,我想知道这是否是一个问题或是否还有其他问题解决方法.

博客文章:

I have found three blog posts about this, but they all seem to be pretty old and I am wondering if this is a problem or if there are other ways to solve it.

Blog Posts:

http://blogs.msdn.com/b/cbrumme/archive /2003/04/17/51361.aspx

http://blogs.msdn.com/b/cbrumme/archive /2004/02/02/66219.aspx

http://stackoverflow.com/questions/896233/how等待消息泵送的等待句柄

基本上,我要问的是要点是,如果绑定"托管线程,到非托管线程,正在等待WaitHandle :: WaitOne(),那么非托管线程的消息泵是否仍处于活动状态?有没有 解决这个问题的方法?会生成一个工作线程,然后加入"一个线程.该工作的主线?还是会有同样的问题?

So basically I am asking, is the main point, that if a managed thread that is "tied" to an unmanaged thread, is waiting on a WaitHandle::WaitOne(), then is the unmanaged thread's message pump still active? Is there a way to get around this? Would spawning a worker thread then "Joining" the main thread to that work? Or would it have the same issues?

谢谢

-Tyzack

推荐答案

tyzack

Hi tyzack,

感谢您访问MSDN论坛.恐怕这不是有关此问题的正确论坛.我将您的问题移至主持人论坛(论坛在哪里.?").论坛的所有者会将您定向到正确的论坛.谢谢你的 理解.

Thank you for visiting the MSDN forum. I’m afraid that it is not the correct forum about this issue. I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum. Thanks for your understanding.


这篇关于WaitOne()是否等待非托管线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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