本文整理汇总了C++中CEvent::SetEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ CEvent::SetEvent方法的具体用法?C++ CEvent::SetEvent怎么用?C++ CEvent::SetEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEvent
的用法示例。
在下文中一共展示了CEvent::SetEvent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsWindow
BOOL
ProgressUIThread::InitInstance ()
{
try
{
ProgressUIDialog * pDlg = new ProgressUIDialog;
m_pMainWnd = pDlg;
MIKTEX_ASSERT (hParentWindow == 0 || IsWindow(hParentWindow));
CWnd * pWnd = 0;
if (hParentWindow != 0)
{
pWnd = CWnd::FromHandle(hParentWindow);
}
BEGIN_USE_MY_RESOURCES()
{
if (! pDlg->Create(IDD_PROGRESS, pWnd))
{
FATAL_WINDOWS_ERROR ("CDialog::Create", 0);
}
}
END_USE_MY_RESOURCES();
hWindow = pDlg->GetSafeHwnd();
MIKTEX_ASSERT (hWindow != 0);
pReadyEvent->SetEvent ();
return (TRUE);
}
catch (const exception &)
{
return (FALSE);
}
}
示例2: Cappacketlivethread
UINT Cappacketlivethread(LPVOID pParam)//抓包线程函数
{
//CMainFrame *p_frame=(CMainFrame*)AfxGetMainWnd();
//int m_exsn=p_frame->m_myprosheet.m_page2.m_thread_num;
//int m_stoptime=p_frame->m_myprosheet.m_page2.m_stoptime;
//int m_thread_index=0;
for(int i=0;i<m_mystruct.m_packetlimit;i++)//线程数目
{
if (::WaitForSingleObject(m_stoptimeup,0)==WAIT_OBJECT_0)
{
//m_thread_index=i;
m_mystruct.m_count=i;
break;
}
pcap_next_ex(m_mystruct.pcap_handle,&m_mystruct.protocol_header,&m_mystruct.pkt_data);//句柄,协议头,数据包
if ((m_mystruct.protocol_header->len)>m_mystruct.m_pl)//判断是否在规定长度以内
{
i--;
continue;
}
pcap_dump((u_char*)m_mystruct.dumpfile,m_mystruct.protocol_header,m_mystruct.pkt_data);
m_mystruct.m_count=i;
}
m_eventEnd.SetEvent();
return 0;
}
示例3: OnClose
void COscillDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
////////////////////////////// Close Serialport //////////////////////////////
//////////////////////////////////////////////////////////////////////////////
m_bRecvThreadRunning = false;
g_eventCommRecv.SetEvent();
if( WAIT_OBJECT_0 != WaitForSingleObject( m_pRecvThread->m_hThread, 100 ) )
{
if ( FALSE == TerminateThread( m_pRecvThread->m_hThread, -2 ) )
{
TRACE( "Terminate RecvThread Failure\r\n" );
// ShowLastError( TEXT( "TerminateThread[RecvThread]" ) );
}
else
{
TRACE( "RecvThread has been terminated!(-2)\r\n" );
}
}
g_COGL.m_bDspyThreadRunning = false;
g_eventDspy.SetEvent();
//glClear would cost 30-80ms
if( WAIT_OBJECT_0 !=
WaitForSingleObject( g_COGL.m_pDspyThread->m_hThread, 100 ) )
{
if ( FALSE == TerminateThread( g_COGL.m_pDspyThread->m_hThread, -1 ) )
{
TRACE( "Terminate DspyThread Failure\r\n" );
// ShowLastError( TEXT( "TerminateThread[DspyThread]" ) );
}
else
{
TRACE( "DspyThread has been terminated!(-1)\r\n" );
}
}
delete g_psQueue;
CDialog::OnClose();
}
示例4: OnPacketReceived
virtual void OnPacketReceived( CTCPPacket *pPacket )
{
if ( g_ClientPacket.Count() < pPacket->GetLen() )
g_ClientPacket.SetSize( pPacket->GetLen() );
memcpy( g_ClientPacket.Base(), pPacket->GetData(), pPacket->GetLen() );
g_ClientPacketEvent.SetEvent();
pPacket->Release();
}
示例5: VMPI_DeletePortalMCSocket
void VMPI_DeletePortalMCSocket()
{
// Stop the thread if it exists.
if ( g_hMCThread )
{
g_MCThreadExitEvent.SetEvent();
WaitForSingleObject( g_hMCThread, INFINITE );
CloseHandle( g_hMCThread );
g_hMCThread = NULL;
}
if ( g_pPortalMCSocket )
{
g_pPortalMCSocket->Release();
g_pPortalMCSocket = NULL;
}
}
示例6: SUCCEEDED
CDownloadTask::~CDownloadTask()
{
BOOL bCOM = SUCCEEDED( OleInitialize( NULL ) );
Transfers.m_pSection.Lock();
if ( Downloads.Check( m_pDownload ) )
m_pDownload->OnTaskComplete( this );
CEvent* pEvent = m_pEvent;
Transfers.m_pSection.Unlock();
if ( pEvent )
pEvent->SetEvent();
delete m_pRequest;
if ( bCOM )
OleUninitialize();
}
示例7: OnTimer
void COscillDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
g_eventCommRecv.SetEvent();
// WaitForSingleObject( m_pRecvThread->m_hThread, INFINITE );
/*
static int m = 0;
static int noldPos = 0;
INSQueue( g_psQueue, g_nTest[m] - 100 );
m = ( m + 1 ) % 200;
// There are still a problem is that when
// m_nSampPerFrame is greater than MAX_SAMP_RECORD.
// Temporarily ignored.
m_nXCnt++;
if ( m_nXCnt >= m_nSampPerFrame )
{
m_nXCnt %= m_nSampPerFrame;
}
m_nNumOfDiv = ( g_psQueue->num - m_nXCnt ) / ( m_nSampPerFrame / 12 );
m_ctrlSbDrawFrame.SetScrollRange( 0, m_nNumOfDiv );
noldPos = m_ctrlSbDrawFrame.GetScrollPos();
m_ctrlSbDrawFrame.SetScrollPos( m_nNumOfDiv, FALSE );
if ( noldPos != m_nNumOfDiv )
{
m_nQueueRearOffset = 0;
UpdateFrame( CLEAR );
}
else
{
UpdateFrame( BASIC );
}
*/
CDialog::OnTimer(nIDEvent);
}
示例8: ExitInstance
int CMMCApp::ExitInstance()
{
try
{
if (GetSockStatus()==0)
{
TRACE("关闭");
//SetSockCloseNei();
EventExit.SetEvent();
}
//delete global_socket;
TRACE("进程即将退出");
LC_ConnectionOper(2);
}
catch (CMemoryException* e)
{
}
catch (CFileException* e)
{
}
catch (CException* e)
{
}
catch(...)
{
}
return CWinApp::ExitInstance();
}
示例9: DataProcess
/*
*********************************************************
* PROCESS THE DATA AND SHARE THEM WITH OTHER SOFTWARE.
*********************************************************
*/
void CDataProcess::DataProcess(){
if(COMM_SHAREDMEM == g_CommunicationSel){
//USING SHARED MEMERY.
BOOL bTimeout = gEventRecv.Lock(INFINITE);
UploadData();
gEventRecv.Unlock();
gEventSend.SetEvent();//SEND DATA.
}
else if(COMM_NETWORK == g_CommunicationSel){
//USING TCP
//UploadData();
//gEventSend.SetEvent();
//TELL THE SERVER TO SEND THE DATA
SetEvent(h_eSingleSpectraSending);
}
else if(COMM_NONE == g_CommunicationSel){
//SetEvent(h_eSingleSpectraSending);
global.series_fifo.append(rq);
}
}
示例10: MarkAsPastedThread
UINT CProcessPaste::MarkAsPastedThread(LPVOID pParam)
{
DWORD startTick = GetTickCount();
static CEvent UpdateTimeEvent(TRUE, TRUE, _T("Ditto_Update_Clip_Time"), NULL);
UpdateTimeEvent.ResetEvent();
Log(_T("Start of MarkAsPastedThread"));
//If running from a U3 device then wait a little before updating the db
//updating the db can take a second or two and it delays the act of pasting
if(g_Opt.m_bU3)
{
Sleep(350);
}
BOOL bRet = FALSE;
int clipId = 0;
try
{
MarkAsPastedData* pData = (MarkAsPastedData*)pParam;
if(pData)
{
clipId = pData->clipId;
if(g_Opt.m_bUpdateTimeOnPaste)
{
try
{
if(pData->pastedFromGroup)
{
CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT clipGroupOrder FROM Main ORDER BY clipGroupOrder DESC LIMIT 1"));
if(q.eof() == false)
{
double latestDate = q.getFloatField(_T("clipGroupOrder"));
latestDate += 1;
Log(StrF(_T("Setting clipId: %d, GroupOrder: %f"), pData->clipId, latestDate));
theApp.m_db.execDMLEx(_T("UPDATE Main SET clipGroupOrder = %f where lID = %d;"), latestDate, pData->clipId);
theApp.RefreshClipOrder(pData->clipId);
}
}
else
{
CppSQLite3Query q = theApp.m_db.execQuery(_T("SELECT clipOrder FROM Main ORDER BY clipOrder DESC LIMIT 1"));
if(q.eof() == false)
{
double latestDate = q.getFloatField(_T("clipOrder"));
latestDate += 1;
Log(StrF(_T("Setting clipId: %d, order: %f"), pData->clipId, latestDate));
theApp.m_db.execDMLEx(_T("UPDATE Main SET clipOrder = %f where lID = %d;"), latestDate, pData->clipId);
theApp.RefreshClipOrder(pData->clipId);
}
}
}
CATCH_SQLITE_EXCEPTION
}
try
{
theApp.m_db.execDMLEx(_T("UPDATE Main SET lastPasteDate = %d where lID = %d;"), (int)CTime::GetCurrentTime().GetTime(), pData->clipId);
}
CATCH_SQLITE_EXCEPTION
delete pData;
bRet = TRUE;
}
}
CATCH_SQLITE_EXCEPTION
Log(_T("End of MarkAsPastedThread"));
DWORD endTick = GetTickCount();
if((endTick-startTick) > 350)
Log(StrF(_T("Paste Timing MarkAsPastedThread: %d, ClipId: %d"), endTick-startTick, clipId));
UpdateTimeEvent.SetEvent();
return bRet;
}
示例11: SetSockClose
extern "C" _declspec(dllexport) int __stdcall SetSockClose()
{
try
{
TRACE("调用SetSockClose1");
if (GetSockStatus()!=0)
{
return 0;
}
if (g_socketServer != INVALID_SOCKET)
{
//g_iClosesignal=1;////主动连接
EventExitBack.ResetEvent();
EventExit.SetEvent();
//shutdown(g_socketServer,SD_SEND);
TRACE("开始等待");
TRACE("threadid %d",hThread);
WaitForSingleObject(EventExitBack,THREADQUITTIME);//hThread
CloseHandle(hThread);
///////////////////////
//Sleep(500);
//_endthreadex((unsigned int)hThread);
TRACE("等待结束");
//Sleep(500);
TRACE("WaitForSingleObject(hThread,INFINITE) return ...\n");
TRACE("子线程退出");
delete pThreadParam;
return 0;
}
return 0;
}
catch (CMemoryException* e)
{
return 30050;
}
catch (CFileException* e)
{
return 30051;
}
catch (CException* e)
{
return 30052;
}
catch(...)
{
return 30053;
}
}
示例12: Receive
//.........这里部分代码省略.........
TRACE("调用CheckWheaverHaveRightData %d",i);
if (i==1)//正确包
{
TRACE("正确数据包");
DataReved * pDataReved=new DataReved(global_socket->pHead,pRightEndTemp);
TRACE("组装接收对象 %d",pDataReved->routeType);
if (pDataReved->routeType==0||pDataReved->routeType==1)//flex
{
/*LC_NSend("LCFlexClient","LCFlexRecvFromNetWork",4,pDataReved->byteDataRecvOrigianl,pDataReved->lengthofbyteDataRecvOrigianl);*/
if (g_LCStatusFlag<=1 )
{
LC_NSend("_airToWeb","airToWebHandler",4,pDataReved->byteDataRecvOrigianl,pDataReved->lengthofbyteDataRecvOrigianl);
}
//to lC control
}
if (pDataReved->routeType==0||pDataReved->routeType==1)//flex
{
TRACE("to mm flag %d",pDataReved->flag);
if (pDataReved->flag==1000)
{
TRACE("设置EventConnectFava");
//::SetEvent(hEvent);
if (strcmp("yes",((ConnectFava*)pDataReved->p_ToDelphiData)->status)==0)
{ iError=0;
TRACE("yes");
Sleep(500);
EventConnectFava.SetEvent();
}
else
{
TRACE("no");
iError=30011;
Sleep(500);
EventConnectFava.SetEvent();
}
}
if (pDataReved->flag==1012)
{
TRACE("设置EventConnectFava");
//::SetEvent(hEvent);
if (((PlayerFava*)pDataReved->p_ToDelphiData)->playerStatus==0||((PlayerFava*)pDataReved->p_ToDelphiData)->playerStatus==1)
{
//iError=((PlayerFava*)pDataReved->p_ToDelphiData)->playerStatus;
iError=0;
TRACE("yes");
Sleep(500);
EventPlayerFava1012.SetEvent();
}
else
{
TRACE("no");
iError=30012;
示例13: DoAcquisition
//.........这里部分代码省略.........
queueIndex = 0;
//continouos data acquisition
while (_isRunning)
{
//wait for notification from the system telling that new data is available
if (WaitForSingleObject(overlapped[queueIndex].hEvent, 5000) == WAIT_TIMEOUT)
{
cout << "\tError on data transfer: timeout occured.\n";
PrintDeviceErrorMessage();
return 0;
}
//get number of actually received bytes...
if (!GT_GetOverlappedResult(_hDevice, &overlapped[queueIndex], &numBytesReceived, false))
{
cout << "\tError on data transfer: couldn't receive number of transferred bytes (GT_GetOverlappedResult() returned FALSE; Windows error code: " << GetLastError() << ")\n";
return 0;
}
//...and check if we lost something (number of received bytes must be equal to the previously allocated buffer size)
if (numBytesReceived != numValidBytes)
{
cout << "\tError on data transfer: samples lost.\n";
return 0;
}
//to store the received data into the application data buffer at once, lock it
_bufferLock.Lock();
__try
{
//if we are going to overrun on writing the received data into the buffer, set the appropriate flag; the reading thread will handle the overrun
_bufferOverrun = (_buffer.GetFreeSize() < nPoints);
//store received data in the correct order (that is scan-wise, where one scan includes all channels)
_buffer.Write((float*) buffers[queueIndex], nPoints);
}
__finally
{
//release the previously acquired lock
_bufferLock.Unlock();
}
//add new GetData call to the queue replacing the currently received one
if (!GT_GetData(_hDevice, buffers[queueIndex], bufferSizeBytes, &overlapped[queueIndex]))
{
cout << "\tError on GT_GetData.\n";
PrintDeviceErrorMessage();
return 0;
}
//signal processing (main) thread that new data is available
_newDataAvailable.SetEvent();
//increment circular queueIndex to process the next queue at the next loop repitition (on overrun start at index 0 again)
queueIndex = (queueIndex + 1) % QUEUE_SIZE;
}
}
__finally
{
cout << "Stopping device and cleaning up..." << "\n";
//stop device
if (!GT_Stop(_hDevice))
{
cout << "\tError on GT_Stop: couldn't stop device.\n";
PrintDeviceErrorMessage();
}
//clean up allocated resources
for (int i = 0; i < QUEUE_SIZE; i++)
{
if (WaitForSingleObject(overlapped[queueIndex].hEvent, timeOutMilliseconds) == WAIT_TIMEOUT)
GT_ResetTransfer(_hDevice);
CloseHandle(overlapped[queueIndex].hEvent);
delete [] buffers[queueIndex];
//increment queue index
queueIndex = (queueIndex + 1) % QUEUE_SIZE;
}
delete [] buffers;
delete [] overlapped;
//reset _isRunning flag
_isRunning = false;
//signal event
_dataAcquisitionStopped.SetEvent();
//end thread
AfxEndThread(0xdead);
}
return 0xdead;
}
示例14: MCThreadCleanupFn
void MCThreadCleanupFn()
{
g_MCThreadExitEvent.SetEvent();
}
示例15: GetSockStatus
extern "C" _declspec(dllexport) int __stdcall SendSync(int flag,void * Pin)
{
try
{
if (flag==1003)
{
if (strlen(((SingleFava*)Pin)->chatTxt)>MAXMESSAGELENGTH)
{
return 30030;
}
}
if (GetSockStatus()!=0)
{
return GetSockStatus();
}
TRACE("调用SendSync flag:%d",flag);
TRACE("调用SendSync flag:%d",flag);
DWORD iErrorNo;
DWORD iRetWait;
g_objectCComAutoCriticalSection.Lock();
TRACE("开始组织数据\n");
CDataClass * pCDataClass=new CDataClass(flag,Pin);
//global_socket->ListInPacket.push(pCDataClass);
global_socket->ListInPacket_Push(pCDataClass);
g_objectCComAutoCriticalSection.Unlock();
EventSend.SetEvent();
//global_socket.AsyncSelect(FD_WRITE);
TRACE("数据完全生成");
TRACE("数据完全生成 开始调用发送");
//int i=SendPackge(g_socketServer);
// g_objectCComAutoCriticalSection.Unlock();
if (flag==1000)
{
TRACE("1000节点 开始等待");
TRACE("开始等待1000");
BOOL i=EventConnectFava.ResetEvent();
int dRet=WaitForSingleObject(EventConnectFava,RECVTIMEOUT);
TRACE("WaitForSingleObject退出");
if(dRet == WAIT_TIMEOUT)
{
TRACE("WaitForSingleObject超时");
EventExit.SetEvent();
return 1460;
}
else if(dRet == WAIT_OBJECT_0)
{
TRACE("WaitForSingleObject正常退出1000________________ iError: %d",iError);
TRACE("正常退出1000________________");
return iError;
}
}
if (flag==1012)
{
EventPlayerFava1012.ResetEvent();
int dRet=WaitForSingleObject(EventPlayerFava1012,RECVTIMEOUT);
if(dRet == WAIT_TIMEOUT)
{
EventExit.SetEvent();
return 1460;
}
else if(dRet == WAIT_OBJECT_0)
{
TRACE("正常退出1000________________");
return iError;
}
/////////////////////////////////////////////////////////////
//.........这里部分代码省略.........