使用CEvent进行线程同步编码 [英] thread synchronization coding using CEvent

查看:103
本文介绍了使用CEvent进行线程同步编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试编写(VISUAL C ++ 6)一个简单的应用程序,该应用程序将帮助我从串行端口读取并使用单个线程写入同一串行端口...所以有人可以帮助我进行管理线程之间的同步.这里是源代码 http://rapidshare.com/files/406340281/SerialPortTest.rar
谢谢
Sayonee

[edit]不要大喊-这是无礼和不必要的.标签已更改. -OriginalGriff [/edit]

hello there I am trying to code(VISUAL C++ 6) a simple application which would help me in reading from a serial port and write to the same serial port using a single thread ...so could someone please help me to manage the synchronization between the threads.heres the source code http://rapidshare.com/files/406340281/SerialPortTest.rar
Thanks
Sayonee

[edit]Don''t shout - it is rude and unnecessary. Tags changed. - OriginalGriff[/edit]

推荐答案

If you write MFC code, I think the simplest way is to use AfxBeginThread to create your work thread, if you want to both reading and writing data to a same port, you can use <pre lang="C++">CCriticalSection</pre>
, CEvent, CMutex or <pre lang="C++">CSemaphore</pre>
if you choose CEvent, you can use <pre lang="C++">WaitForSingleObject</pre>
to wait your CEvent object


这篇关于使用CEvent进行线程同步编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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