b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

waitforsingleobject_setevent_创建线程函数(6)

电脑杂谈  发布时间:2016-12-26 15:07:10  来源:网络整理

//...

}

BOOLCTestThreadApp::WaitMyEvent(HANDLEhObject)

{

while(TRUE)

{

MSGmsg;

while(PeekMessage(&msg,NULL,0,0,PM_REMOVE))

{

//Ifit'saquitmessage,we'reoutofhere.

if(msg.message==WM_QUIT)

returnFALSE;

//Otherwise,dispatchthemessage.

TranslateMessage(&msg);

DispatchMessage(&msg);

}//EndofPeekMessagewhileloop.

//Waitforanymessagesentorpostedtothisqueue

//orforoneofthepassedhandlesbesettosignaled.

DWORDresult=MsgWaitForMultipleObjects(1,&m_hEvent,

FALSE,INFINITE,QS_ALLINPUT);

if(result==WAIT_OECT_0)

returnTRUE;

}

}

//用户界面线程为:

#defineWM_TEST(WM_USER+1)

classCMyUIThread:publicCWinThread

{

DECLARE_DYNCREATE(CMyUIThread)

protected:

CMyUIThread();//protectedconstructorusedbydynamiccreation

//Operations

public:

//Overrides

//ClassWizardgeneratedvirtualfunctionoverrides

//{{AFX_VIRTUAL(CMyUIThread)

public:

virtualBOOLInitInstance();

virtualintExitInstance();

//}}AFX_VIRTUAL

//Implementation

protected:

virtual~CMyUIThread();

LRESULTOnTest(WPARAMwParam,LPARAMlParam);

DECLARE_MESSAGE_MAP()

};

//MyUIThread.cpp:implementationfile

#include"stdafx.h"

#include"TestThread.h"

#include"MyUIThread.h"

IMPLEMENT_DYNCREATE(CMyUIThread,CWinThread)

CMyUIThread::CMyUIThread()

{}

CMyUIThread::~CMyUIThread()

{}

BOOLCMyUIThread::InitInstance()

{

//TODO:performandper-threadinitializationhere

returnTRUE;

}

intCMyUIThread::ExitInstance()

{

//TODO:performanyper-threadcleanuphere

returnCWinThread::ExitInstance();

}

BEGIN_MESSAGE_MAP(CMyUIThread,CWinThread)

//{{AFX_MSG_MAP(CMyUIThread)

//NOTE-theClassWizardwilladdandremovemappingmacroshere.


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-23463-6.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    • 郎光娅
      郎光娅

      更是凭着优异的航速和猛烈的火力

    热点图片
    拼命载入中...