zoukankan      html  css  js  c++  java
  • 03EventDemo

     1 #include<stdio.h>
     2 #include<stdlib.h>
     3 #include<process.h>
     4 #include<windows.h>
     5 
     6 HANDLE g_hEvent;
     7 UINT __stdcall ThreadProc(LPVOID);
     8 int main(int argc,char* argv[])
     9 {
    10     unsigned uThreadId;
    11     char szEventName[] = "MyEvent";
    12     HANDLE hThread = (HANDLE)::_beginthreadex(NULL,0,ThreadProc,NULL,0,&uThreadId);
    13     g_hEvent = ::CreateEvent(NULL,false,false,szEventName);
    14     printf("Input something to go on!
    ");
    15     getchar();
    16     ::SetEvent(g_hEvent);
    17     ::WaitForSingleObject(hThread,INFINITE);
    18     printf("The Thread has been finished all works!
    ");
    19     ::CloseHandle(g_hEvent);
    20     ::CloseHandle(hThread);
    21     
    22     system("pause");
    23     return 0;
    24 }
    25 UINT __stdcall ThreadProc(LPVOID lpParam)
    26 {
    27     ::WaitForSingleObject(g_hEvent,INFINITE);
    28     printf("Thread are runing!
    ");
    29     Sleep(2000);
    30     return 0;
    31 }
  • 相关阅读:
    openssh的服务端配置文件
    SSH的端口转发
    ssh服务
    文件引入
    数据类型的转换
    作用域
    静态变量
    函数
    php嵌入html的解析过程
    PHP执行过程
  • 原文地址:https://www.cnblogs.com/FWFC/p/6360483.html
Copyright © 2011-2022 走看看