文章分类 | 推荐文章 | 最新文章 | 热点文章 | 最新软件 | 精品软件 | 下载排行 | 推荐下载 | 免费看大片 | WPS | 杀毒软件
清风网络
首 页 软件下载 网络学院 数码学院
QQ 电脑入门 游戏 操作系统 图形处理 办公软件 媒体动画 精文荟萃 工具软件 网络编程 程序开发 网络技术 认证考试 网站建设 文章专栏
当前位置:清风网络学院程序开发C/C++深入浅出Win32多线程程序设计之综合实例
精品推荐
特别推荐
·C语言编程易犯毛病集合
·C语言编程常见问题解答(目录)
·C#程序开发中的常用函数汇总
·C/C++笔试、面试题目大汇总
·Beej的网络socket编程指南
·socket编程原理
·C语言的常用库函数使用方法分析及用途
·在C语言中如何处理时间和日期
·C++设计模式之Singleton
·VC++动态链接库编程之MFC扩展 DLL
热点TOP10
·进程和线程编程
·C语言编程易犯毛病集合
·打字游戏
·Awk 基础入门:Awk 实例编程
·asp.net中调用javascript函数实现多功能日期控件示例
·C语言编程常见问题解答之常用函数的包含文件(1)
·C# GridView 排序及分页
·C #中的几个线程同步对象方法
·无废话C#设计模式之三:Abstract Factory
·C# DataGridView隔行显示不同的颜色

深入浅出Win32多线程程序设计之综合实例

日期:2008年6月6日 作者: 查看:[大字体 中字体 小字体]


      // occured. Process this error.
      port->ProcessErrorMessage("WaitCommEvent()");
      break;
     }
    }
   }
   else
   {
    // If WaitCommEvent() returns TRUE, check to be sure there are
    // actually bytes in the buffer to read.
    //
    // If you are reading more than one byte at a time from the buffer
    // (which this program does not do) you will have the situation occur
    // where the first byte to arrive will cause the WaitForMultipleObjects()
    // function to stop waiting. The WaitForMultipleObjects() function
    // resets the event handle in m_OverlappedStruct.hEvent to the non-signelead state
    // as it returns.
    //
    // If in the time between the reset of this event and the call to
    // ReadFile() more bytes arrive, the m_OverlappedStruct.hEvent handle will be set again
    // to the signeled state. When the call to ReadFile() occurs, it will
    // read all of the bytes from the buffer, and the program will
    // loop back around to WaitCommEvent().
    //
    // At this point you will be in the situation where m_OverlappedStruct.hEvent is set,
    // but there are no bytes available to read. If you proceed and call
    // ReadFile(), it will return immediatly due to the async port setup, but
    // GetOverlappedResults() will not return until the next character arrives.
    //
    // It is not desirable for the GetOverlappedResults() function to be in
    // this state. The thread shutdown event (event 0) and the WriteFile()
    // event (Event2) will not work if the thread is blocked by GetOverlappedResults().
    //
    // The solution to this is to check the buffer with a call to ClearCommError().
    // This call will reset the event handle, and if there are no bytes to read
    // we can loop back through WaitCommEvent() again, then proceed.
    // If there are really bytes to read, do nothing and proceed.

    bResult = ClearCommError(port->m_hComm, &dwError, &comstat);

    if (comstat.cbInQue == 0)
     continue;
   } // end if bResult

   // Main wait function. This function will normally block the thread
   // until one of nine events occur that require action.
   Event = WaitForMultipleObjects(3, port->m_hEventArray, FALSE, INFINITE);

   switch (Event)
   {
    case 0:
    {
     // Shutdown event. This is event zero so it will be

上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] 下一页 




上一篇:C++箴言:理解typename的两个含义

下一篇:C++箴言:谨慎使用多继承

相关文章:
·Photoshop CS3合成实例:人间天堂
·DataList嵌套实例
·Photoshop实例:制作超酷影片画面场景
·综合实例:PS洗衣粉包装设计印刷全攻略
·Photoshop精细抠像实例
·PS初学者实例教程 烫金字的制作
·进程和线程编程
·[综合交流]母矿、矿石、魔法石、召唤石的出处
·[综合]《武林外传》内测账号密码修改指南
·Flash动画制作实例:小野人玩摇滚
相关软件:
·C语言程序设计
·中文版Excel 2003实例与技巧
·CorelDraw12 入门与实例(图文教程 菜鸟先飞系列教材)
·AutoCAD2002入门与实例详解
·Windows环境下32位汇编语言程序设计
·Flash MX 动画制作实例教程
·注册表实例应用视频教程swf
·英语自考-综合英语(一)上册 - 第01讲(全16讲)
·PhotoShop7 设计百例 + 经典实例教程 + 滤镜教学
·AUTOCAD 2002机械设计应用与实例

特别声明:本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
[打印本页] [关闭窗口] 转载请注明来源:http://www.viphot.com
| 帮助(?) | 版权声明 | 友情连接 | 关于我们 | 信息发布
Copyright 2007 www.viphot.com All Rights Reserved. 鄂ICP备05000083号Powered by:viphot