加入收藏 | 设为首页 | 会员中心 | 我要投稿 | RSS
您当前的位置:首页 > 学习资料

非滞后式延迟执行

时间:2021-03-22 00:13:48  来源:  作者:
方法如下
建立 xsleep.cpp和xsleep.p文件
xsleep.cpp文件代码如下
  1. //Download by http://www.cncml.com
  2. #include <windows.h>
  3. #include <stdafx.h>
  4.  
  5. // This structure is used internally by the XSleep function
  6. struct XSleep_Structure
  7. {
  8.         int duration;
  9.         HANDLE eventHandle;
  10. };
  11.  
  12.  
  13. //////////////////////////////////////////////////////////////////////
  14. // Function  : XSleepThread()
  15. // Purpose   : The thread which will sleep for the given duration
  16. // Returns   : DWORD WINAPI
  17. // Parameters:      
  18. //  1. pWaitTime -
  19. //////////////////////////////////////////////////////////////////////
  20. DWORD WINAPI XSleepThread(LPVOID pWaitTime)
  21. {
  22.         XSleep_Structure *sleep = (XSleep_Structure *)pWaitTime;
  23.  
  24.         Sleep(sleep->duration);
  25.         SetEvent(sleep->eventHandle);
  26.  
  27.         return 0;
  28. }
  29.  
  30. //////////////////////////////////////////////////////////////////////
  31. // Function  : XSleep()
  32. // Purpose   : To make the application sleep for the specified time
  33. //             duration.
  34. //             Duration the entire time duration XSleep sleeps, it
  35. //             keeps processing the message pump, to ensure that all
  36. //             messages are posted and that the calling thread does
  37. //             not appear to block all threads!
  38. // Returns   : none
  39. // Parameters:      
  40. //  1. nWaitInMSecs - Duration to sleep specified in miliseconds.
  41. //////////////////////////////////////////////////////////////////////
  42. void XSleep(int nWaitInMSecs,int nAscll)
  43. {
  44.                
  45. <blockquote><span class="Apple-tab-span" style="white-space:pre">        </span>INPUT input[2];
复制代码


xsleep.h文件代码
 
  1. //Download by http://www.cncml.com
  2. #ifndef _XSLEEP_H_
  3. #define _XSLEEP_H_
  4.  
  5. void XSleep(int nWaitInMSecs, int nAscll);
  6.  
  7. #endif // _XSLEEP_H_
  8.  
复制代码


mfc中的调用代码如下
  1. int ascll;
复制代码
  1. XSleep(500,ascll);
复制代码

 
来顶一下
返回首页
返回首页
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表
推荐资讯
实现php间隔一段时间执行一次某段代码
实现php间隔一段时间
相关文章
    无相关信息
栏目更新
栏目热门