void CDebugger::FunctionHook(const char *szFile, int nLine, BOOL bCall) { if ( m_nMode == DMOD_STOP && !m_ExternalDebugging) EndThread(); m_nLevel += (bCall?1:-1); }
void CServerSocketThread::createServer(void) { try { while ( true ) { //TODO:cria um socket para o cliente CBugSocket * newSocket = serverSocket->Accept(); CClientSocketThread * newClient = new CClientSocketThread(newSocket); //adiciona na lista EnterCriticalSection(&sessaoCritica); connectList.push_back(newClient); LeaveCriticalSection(&sessaoCritica); //inicia o while newClient->startReceiveThread(); } } catch (...) { EndThread(); //std::cout << "Erro para criar o servidor: " << e.description() << "\nSaindo.\n"; } }
BOOL CGtecDevice::EB_Stop() { //close the device and exit the thread. EndThread(); return GT_Stop(m_hDevice); }
void CDebugger::LineHook(const char *szFile, int nLine) { if ( m_nMode == DMOD_STOP && !m_ExternalDebugging) { EndThread(); } BOOL hasBreakPoint = false; if (m_ExternalDebugging) { if (theApp.GetMainFrame()->GetProject()->IsBreakPointPossibleAtLine(nLine)) { hasBreakPoint = theApp.GetMainFrame()->GetProject()->HasBreakPoint(szFile, nLine); } } else { hasBreakPoint = ::SendMessage(m_hWndMainFrame, DMSG_HAS_BREAKPOINT, (WPARAM)szFile, (LPARAM)nLine); } if (m_nMode==DMOD_STEP_INTO || m_nMode==DMOD_BREAK || (m_nMode==DMOD_STEP_OVER && m_nLevel<=0) || (m_nMode==DMOD_STEP_OUT && m_nLevel<0) || (m_nMode==DMOD_RUN_TO_CURSOR && m_strPathName.CompareNoCase(szFile)==0 && m_nLine==nLine) ) { if (m_EvaluatingCondition) return; DebugBreak(szFile, nLine); } else if (hasBreakPoint) { if (m_EvaluatingCondition) return; // check that the condition for this breakpoint is met CProjectFile::CBreakPoint bp; if (theApp.GetMainFrame()->GetProject()->GetBreakPoint(szFile, nLine, bp)) { if (bp.m_Enabled) { if (bp.m_Condition.IsEmpty()) { DebugBreak(szFile, nLine); } else { CString evalCond = Eval(bp.m_Condition); if (evalCond != "nil" && evalCond != "false") { DebugBreak(szFile, nLine); } } } } else { DebugBreak(szFile, nLine); } } }
void CBiteThroldWnd::OnDestroy() { // TODO: end thread and release the resource EndThread(m_hThread); m_hThread = INVALID_HANDLE_VALUE; OnOK(); __super::OnDestroy(); }
CThread::~CThread() { try { Terminate(); EndThread(); } catch (...) { _Done(); // throw; } _Done(); }
CTimer::~CTimer() { SetActive(false); EndThread(); if ( INVALID_HANDLE_VALUE != m_hThreadHandle ) { WaitForSingleObject(m_hThreadHandle, INFINITE); } }
int Transfer::Stop() { if(EndThread() != 0) { LOG(LEVEL_ERROR, "End Thread Failed"); } delete _tfm; return 0l; }
//-------------------------------------------------------------------------------- CSecurityClient::~CSecurityClient() { SetTargetNone(); EndThread(); if(m_pConnection != NULL) { m_pConnection->EndConnection(); delete m_pConnection; } CancelDeadlineTimer(); }
recChannel_t::~recChannel_t(void) { __CONTEXT("recChannel_t::~recChannel_t"); IBaseFilter * pFilter = NULL; if (camInfo->getKind() == TEST) { looper->EndThread(); } unmap(); camList->lookUp(sourceId)->setFree(true); pControl->Stop(); looper->EndThread(); delete looper; delete pSender; remap(); int hr = 0; // Enumerate the filters in the graph. IEnumFilters *pEnum = NULL; hr = pGraph->EnumFilters(&pEnum); if (SUCCEEDED(hr)) { IBaseFilter *pFilter = NULL; while (S_OK == pEnum->Next(1, &pFilter, NULL)) { pGraph->RemoveFilter(pFilter); pFilter->Release(); pEnum->Reset(); } pEnum->Release(); } pControl->Release(); pEvent->Release(); pGraph->Release(); channelList->remove(getId()); rtpSession->deleteSender (getId(), "Channel deleted"); #ifdef _WINDOWS EndThread(); TerminateThread(hThread,0); #endif }
FILEMONITOR_PROC( void, EndMonitor )( PMONITOR monitor ) { if( !monitor ) return; if( monitor->flags.bDispatched || monitor->flags.bScanning ) { monitor->flags.bEnd = 1; return; } if( monitor->flags.bClosing ) { if( l.flags.bLog ) Log( WIDE("Monitor already closing...") ); return; } EnterCriticalSec( &monitor->cs ); monitor->flags.bClosing = 1; monitor->flags.bRemoveFromEvents = 1; if( !monitor->flags.bRemovedFromEvents ) { SetEvent( l.hMonitorThreadControlEvent ); while( !monitor->flags.bRemovedFromEvents ) Relinquish(); } //Log1( WIDE("Closing the monitor on %s and killing thread...") // , monitor->directory ); if( monitor->hChange != INVALID_HANDLE_VALUE ) { lprintf( WIDE( "close ntoification (wakes thread?" ) ); FindCloseChangeNotification( monitor->hChange ); lprintf( WIDE( "and then we wait..." ) ); } monitor->hChange = INVALID_HANDLE_VALUE; { uint32_t tick = timeGetTime(); while( monitor->pThread && ( ( tick+50 ) > timeGetTime() ) ) Relinquish(); } if( monitor->pThread ) { EndThread( monitor->pThread ); } //else // Log( WIDE("Thread already left...") ); CloseFileMonitors( monitor ); RemoveTimer( monitor->timer ); UnlinkThing( monitor ); LeaveCriticalSec( &monitor->cs ); Release( monitor ); }
UINT CDebugger::StartDebugger() { m_nLine = 0; m_nLevel = 0; ::SendMessage(m_hWndMainFrame, DMSG_DEBUG_START, 0, 0); int nRet = m_lua.StartDebugger(); if (!m_ExternalDebugging) { EndThread(); } return nRet; }
static int CPROC Close( PCONSOLE_INFO pdp ) { EndThread( pdp->consolecon.pThread ); CloseHandle( pdp->consolecon.hStdout ); CloseHandle( pdp->consolecon.hStdin ); FreeConsole(); pdp->consolecon.hStdout = NULL; pdp->consolecon.hStdin = NULL; #ifdef __DEKWARE_PLUGIN__ pdp->common.Close = NULL; pdp->common.Write = NULL; pdp->common.Read = NULL; pdp->common.Type = 0; #endif return 1; }
void FileChangeWatcher::Shutdown() { if (m_thread != NULL) { EndThread(); m_thread = NULL; } if (m_handle != NULL) { FindCloseChangeNotification(m_handle); m_handle = NULL; } CloseHandle(m_threadEndEvent); m_threadEndEvent = NULL; }
void CDebugger::DebugBreak(const char *szFile, int nLine) { m_nMode = DMOD_NONE; ::SendMessage(m_hWndMainFrame, DMSG_GOTO_FILELINE, (WPARAM)szFile, (LPARAM)nLine); m_lua.DrawStackTrace(); m_lua.DrawGlobalVariables(); ::SendMessage(m_hWndMainFrame, DMSG_GOTO_STACKTRACE_LEVEL, 0, 0); ::SendMessage(m_hWndMainFrame, DMSG_REDRAW_WATCHES, 0, 0); ResetEvent(); ::SendMessage(m_hWndMainFrame, DMSG_DEBUG_BREAK, 0, 0); if (m_ExternalDebugging) { theApp.GetMainFrame()->ShowWindow(SW_SHOW); SetForegroundWindow(theApp.GetMainFrame()->m_hWnd); // pump event until main loop returns to "Debug" instead of "Debug break" WCHAR tmpTitle[1024]; GetWindowTextW(theApp.m_EmbeddingAppWnd, tmpTitle, 1024); SetWindowText(theApp.m_EmbeddingAppWnd, "Lua breaked"); while (!m_monoThreadEvent) { theApp.MainLoop(); if (theApp.m_DebuggedAppMainLoop) { theApp.m_DebuggedAppMainLoop->breakEventLoop(); } } SetWindowTextW(theApp.m_EmbeddingAppWnd, tmpTitle); } else { CSingleLock lock(&m_event, TRUE); } if ( m_nMode == DMOD_STOP && !m_ExternalDebugging) EndThread(); }
void CTimer::Run() { while(!m_bEnd) { if (!m_bActive) { Sleep(delay); continue; } __try { Running(); Sleep(delay); } __except( EXCEPTION_EXECUTE_HANDLER ) { EndThread(); } } }
void FileChangeWatcher::SetFile(const wxFileName& fileName) { // If the file is in the same directory, we don't need to update anything. bool sameDirectory = (fileName.GetPath() == m_fileName.GetPath()); m_fileName = fileName; UpdateFileAttributes(); if (!sameDirectory || m_handle == NULL) { if (m_thread != NULL) { EndThread(); } if (m_handle != NULL) { FindCloseChangeNotification(m_handle); m_handle = NULL; } m_handle = FindFirstChangeNotification(m_fileName.GetPath(), FALSE, FILE_NOTIFY_CHANGE_ATTRIBUTES); // Sometimes the return is NULL and sometimes it's INVALID_HANDLE_VALUE // in error conditions. if (m_handle == INVALID_HANDLE_VALUE) { m_handle = NULL; } if (m_handle != NULL) { DWORD threadId; m_thread = CreateThread(NULL, 0, ThreadProc, this, 0, &threadId); } } }
//启动线程 bool CThread::StartThead() { //效验状态 if (IsRuning()) return false; //清理变量 if (m_hThreadHandle!=NULL) { CloseHandle(m_hThreadHandle); m_hThreadHandle=NULL; m_uThreadID=0; } //构造参数 tagThreadParameter ThreadParameter; ThreadParameter.bSuccess=false; ThreadParameter.m_pServiceThread=this; ThreadParameter.hEventFinish=CreateEvent(NULL,FALSE,FALSE,NULL); if (ThreadParameter.hEventFinish==NULL) return false; //启动线程 m_bRun=true; m_hThreadHandle=(HANDLE)::_beginthreadex(NULL,0,ThreadFunction,&ThreadParameter,0,&m_uThreadID); //等待事件 WaitForSingleObject(ThreadParameter.hEventFinish,INFINITE); //关闭事件 CloseHandle(ThreadParameter.hEventFinish); //判断错误 if (ThreadParameter.bSuccess==false) { EndThread(); return false; } return true; }
BOOL EmotivRead::EB_Stop() { EndThread(); return TRUE; }
int recChannel_t::select_source(camInfo_t * source) { __CONTEXT("recChannel_t::select_source"); if (camInfo) { if (camInfo->getKind() == TEST) { looper->EndThread(); } #ifdef _WINDOWS if (camInfo->getKind() == MEDIA) { EndThread(); } #endif camInfo->setFree(true); } int hr = 0; pControl->StopWhenReady(); //pControl->Stop(); bool sharedDisplaySource = false; RECT sharedDisplayRect; char auxName[100]; if (source != NULL) { if (!(source->getKind() == CAM || source->getKind() == SHARED)) { capInfo.heigth = 0; capInfo.width = 0; }else{ if (source->getKind() == CAM) { if (!capInfo.heigth) capInfo.heigth = DEFAULT_CAPTURE_HEIGTH; if (!capInfo.width) capInfo.width = DEFAULT_CAPTURE_WIDTH; } if (source->getKind() == SHARED) { sharedDisplay_t * sharedDisplay = static_cast<sharedDisplay_t *>(source); sharedDisplayRect = sharedDisplay->getSharedRect(); capInfo.heigth = sharedDisplayRect.bottom - sharedDisplayRect.top; capInfo.width = sharedDisplayRect.right - sharedDisplayRect.left; mapping = true; //always mapping shDisplay channel sharedDisplaySource = true; strcpy(auxName,source->getCamName()); } } } refresh_channel(all); if (sharedDisplaySource && pSource == NULL) { camInfo_t *camInfo = createSharedDisplay(this,auxName); sharedDisplay_t *sharedDisplay = static_cast<sharedDisplay_t *>(camInfo); sharedDisplay->setSharedRect(sharedDisplayRect); } #ifdef _WINDOWS if (source->getKind() == MEDIA) { if (fControl) { if (source!=camInfo) { fControl->m_slide.SetPos(0); } } RunThread(); } #endif camInfo = source; pOutput = camInfo->output; pOutput->Disconnect(); sourceId = camInfo->getID(); if (!strlen(sourceFormat)) { memset(sourceFormat,0,100); char supportedFormats[100]; strcpy(supportedFormats,camInfo->getSupportedFormats()); for (int j=1;supportedFormats[j]!=';';j++) sourceFormat[j-1]=supportedFormats[j]; ql_t<AM_MEDIA_TYPE *> auxFormats = camInfo->getFormatList(); actualFormat = *(auxFormats.nth(0)); for (int k=0;k<auxFormats.len() ; k++) { AM_MEDIA_TYPE format = *(auxFormats.nth(k)); char subtypeName [100]; memset(subtypeName,0,100); GetGUIDString(subtypeName,&format.subtype); if (strcmp(subtypeName,"MEDIASUBTYPE_RGB24")==0) { actualFormat = format; strcpy(sourceFormat,"MEDIASUBTYPE_RGB24"); } } } pSource = camInfo->pSource; hr = pGraph->AddFilter(pSource, L"Capture Video Source"); errorCheck(hr); hr = grab_geometry(capInfo); camInfo->setFree(false); //leave critical section return hr; }
/** * The destructor stops the thread. If the thread has already stoppped, destructor does nothing. */ UploadBandwidthThrottler::~UploadBandwidthThrottler() { EndThread(); }
CLIENTMSG_PROC( void, UnloadService )( CTEXTSTR name ) { PEVENTHANDLER pHandler; pHandler = g.pHandlers; while( pHandler ) { if( StrCaseCmp( pHandler->servicename, name ) == 0 ) break; pHandler = pHandler->next; } if( pHandler ) { MSGIDTYPE Responce; //lprintf( WIDE("Unload service: %s"), pHandler->servicename ); if( pHandler->flags.local_service ) { //lprintf( WIDE("Local service... resulting quick success...") ); Responce = (MSG_ServiceUnload)|SERVER_SUCCESS; } else { //lprintf( WIDE("Requesting message %d from %d "), MSG_ServiceUnload , pHandler->MsgBase ); Responce = ((MSG_ServiceUnload)|SERVER_SUCCESS); if( !TransactServerMessage( &pHandler->RouteID , MSG_ServiceUnload, NULL, 0 , &Responce/*NULL*/, NULL, 0 ) ) { lprintf( WIDE("Transaction to ServiceUnload failed...") ); } else if( Responce != ((MSG_ServiceUnload)|SERVER_SUCCESS) ) { lprintf( WIDE("Server reports it failed to unload the service %08") _MsgID_f WIDE(" %08") _MsgID_f WIDE("") , Responce, (MSGIDTYPE)((MSG_ServiceUnload)|SERVER_SUCCESS) ); // no matter what the result, this must still release this // resource.... //return; } while( pHandler->flags.dispatched ) { Relinquish(); } } UnlinkThing( pHandler ); //lprintf( WIDE("Release? wow release hangs forever?") ); //Release( pHandler ); if( 0 && !g.pHandlers ) { Log( WIDE("No more services loaded - killing threads, disconnecting") ); if( g.pLocalEventThread ) { EndThread( g.pLocalEventThread ); // wake up the thread... } if( g.pEventThread ) EndThread( g.pEventThread ); if( g.pThread ) EndThread( g.pThread ); CloseMessageQueues(); g.flags.events_ready = 0; g.flags.local_events_ready = 0; g.flags.failed = 0; g.flags.message_handler_ready = 0; g.flags.message_responce_handler_ready = 0; } //Log( WIDE("Done unloading services...") ); return; } Log( WIDE("Service was already Unloaded!?!?!?!?!?") ); }
CThread::~CThread(void) { EndThread(INFINITE); }
BOOL CCommMng::EndRecvThread() { return EndThread(); }
SysThread::~SysThread() { EndThread(); }
/** * The destructor stops the thread. If the thread has already stoppped, destructor does nothing. */ UploadBandwidthThrottler::~UploadBandwidthThrottler(void) { EndThread(); delete threadEndedEvent; delete pauseEvent; }
CThreadObject::~CThreadObject() { EndThread(1000); CloseHandle(m_evtStart); CloseHandle(m_evtStop); }