Click here to Skip to main content
15,894,546 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Why do i can not delete Registry Keys ? Pin
David Crow2-May-08 5:05
David Crow2-May-08 5:05 
AnswerRe: Why do i can not delete Registry Keys ? Pin
Hamid_RT2-May-08 5:06
Hamid_RT2-May-08 5:06 
QuestionAfter alt-tab, my program thinks that the alt key is still down Pin
Anthony Appleyard1-May-08 12:13
Anthony Appleyard1-May-08 12:13 
AnswerRe: After alt-tab, my program thinks that the alt key is still down Pin
Randor 1-May-08 13:02
professional Randor 1-May-08 13:02 
GeneralRe: After alt-tab, my program thinks that the alt key is still down Pin
Anthony Appleyard2-May-08 10:51
Anthony Appleyard2-May-08 10:51 
QuestionThreads in Windows service Pin
RoyceF1-May-08 11:39
RoyceF1-May-08 11:39 
AnswerRe: Threads in Windows service Pin
Blake Miller1-May-08 12:00
Blake Miller1-May-08 12:00 
GeneralRe: Threads in Windows service Pin
RoyceF1-May-08 15:38
RoyceF1-May-08 15:38 
I appreciate any help. I have posted my code below:

<br />
void CFileChangeEvent::stopProcessThread()<br />
{<br />
	TRACE( "> > > > CFileChangeEvent::stopProcessThread() entered - Event handles < %X, %X >, Event ID < %s >\n",<br />
					m_hProcessStopEvent, m_hProcessRespEvent, getIdentifier() );<br />
<br />
	//	The ProcessStopEvent is used by the main thread to tell the worker thread to stop. <br />
	//	In turn, the worker thread sets the ProcessRespEvent to tell the main thread that it has stopped. <br />
	::SetEvent( m_hProcessStopEvent );<br />
}<br />
<br />
UINT CFileChangeEvent::MultiFileProcessThread( LPVOID lpParam )<br />
{<br />
	// This is the threaded multi-file processor. It searches for and processes all raw flight data<br />
	//	(*.FIF files) in the Inbox or until it is cancelled by a call from DataMovement due to<br />
	//	a Cancel message from PC-GBS.<br />
	CFileChangeEvent* pEvent = (CFileChangeEvent*)lpParam;<br />
<br />
	CFlightDataHandler* pFlightDataHandler = NULL;<br />
	CLogWriter* pLogWriter = NULL;<br />
	HANDLE hProcessStopEvent = pEvent->getProcessStopEvent();<br />
	HANDLE hProcessRespEvent = pEvent->getProcessRespEvent();<br />
<br />
	// We use this exception handling merely to protect this service<br />
	//	from being crashed by an unhandled exception. Errors are <br />
	//	generally handled and logged within the DLL by the LogWriter.<br />
	try<br />
	{<br />
		CDataMovement* pDataMovement = pEvent->getDataMovementParent();<br />
		CLogWriter* pLogWriter = pDataMovement->getLogWriter();<br />
		pFlightDataHandler = new CFlightDataHandler( pLogWriter );<br />
<br />
		// We must call ::CoInitialize() each time the database is accessed<br />
		HRESULT hRes = ::CoInitialize(NULL);<br />
<br />
		CString strInboxPath( pDataMovement->getInboxPath() );<br />
		vector<CString> vecFifFiles = UtilK::findAllFiles( "*.fif", strInboxPath );<br />
<br />
		// The input file parameter points to a single *.fif file, but we <br />
		//	need to extract the folder just below the Inbox path so that<br />
		//	all flight data in that path can be processed<br />
		int nLen = strInboxPath.GetLength() + 1;<br />
		vector<CString>::iterator iterFile = vecFifFiles.begin();<br />
		CString strFile = *iterFile;<br />
		CString strLastPath = (*iterFile).Mid( 0, strFile.Find( "\\", nLen ) );<br />
<br />
		int nFileCount = 0;<br />
		bool bCancelled = false;<br />
		for( ; iterFile != vecFifFiles.end()  &&  ! bCancelled;  iterFile++ )<br />
		{<br />
			CString strPath = UtilK::getFsPart( *iterFile, UtilK::FsPath );<br />
			pFlightDataHandler->importRawFlightData( strPath );<br />
<br />
			DWORD dwWaitStatus = ::WaitForSingleObject( hProcessStopEvent, 1 ); <br />
			if ( dwWaitStatus == WAIT_FAILED )<br />
				bCancelled = true;<br />
			else if ( dwWaitStatus == WAIT_OBJECT_0 )<br />
				bCancelled = true;<br />
		}<br />
	}<br />
	catch( CMultiLevelException e )<br />
	{<br />
		CString strMsg;<br />
		strMsg.Format( "importVARFile() failed - error description is %s", e.getUserMessage() );<br />
		<br />
		TRACE( "> > > > CFileChangeEvent::MultiFileProcessThread() exception < %s >\n", strMsg );<br />
		if ( pLogWriter )<br />
			pLogWriter->writeEntry( "CFileChangeEvent", CLogWriter::LE_OPERATION_FAILED, strMsg );<br />
	}<br />
	catch(...)<br />
	{<br />
		CString strMsg( "importVARFile() failed with unexpected exception" );<br />
		TRACE( "> > > > CFileChangeEvent::MultiFileProcessThread() exception < %s >\n", strMsg );<br />
		if ( pLogWriter )<br />
			pLogWriter->writeEntry( "CVarFileEvent", CLogWriter::LE_OPERATION_FAILED, strMsg );<br />
	}<br />
<br />
	if ( pFlightDataHandler )<br />
		delete pFlightDataHandler;<br />
<br />
	CFileChangeEvent::setProcessCompleted();<br />
<br />
	TRACE( "> > > > CFileChangeEvent::MultiFileProcessThread() exiting\n" );<br />
<br />
	::CoUninitialize();<br />
<br />
	if ( hProcessStopEvent )<br />
		::CloseHandle( hProcessStopEvent );<br />
<br />
	if ( hProcessRespEvent )<br />
	{<br />
		::SetEvent( hProcessRespEvent );<br />
		::CloseHandle( hProcessRespEvent );<br />
	}<br />
<br />
	::AfxEndThread( 0 );<br />
<br />
	return 1;<br />
}<br />

GeneralRe: Threads in Windows service Pin
Blake Miller2-May-08 4:34
Blake Miller2-May-08 4:34 
Question"MSDN Library for Visual Studio 2008 - ENU" update problem Pin
followait1-May-08 11:06
followait1-May-08 11:06 
QuestionRe: "MSDN Library for Visual Studio 2008 - ENU" update problem Pin
Hamid_RT2-May-08 5:04
Hamid_RT2-May-08 5:04 
AnswerRe: "MSDN Library for Visual Studio 2008 - ENU" update problem Pin
Mark Salsbery2-May-08 5:42
Mark Salsbery2-May-08 5:42 
QuestionHow to Convert CString to TChAR Pin
Larry Mills Sr1-May-08 10:06
Larry Mills Sr1-May-08 10:06 
AnswerRe: How to Convert CString to TChAR Pin
David Crow1-May-08 10:27
David Crow1-May-08 10:27 
AnswerRe: How to Convert CString to TChAR Pin
Randor 1-May-08 16:57
professional Randor 1-May-08 16:57 
AnswerRe: How to Convert CString to TChAR Pin
Rajkumar R1-May-08 20:30
Rajkumar R1-May-08 20:30 
Questionvs2008 problem, about F1 and type mismatch Pin
followait1-May-08 8:44
followait1-May-08 8:44 
Questionhow can i do this with C++ Pin
reteset1-May-08 4:22
reteset1-May-08 4:22 
AnswerRe: how can i do this with C++ Pin
led mike1-May-08 6:21
led mike1-May-08 6:21 
AnswerRe: how can i do this with C++ Pin
Maximilien1-May-08 7:03
Maximilien1-May-08 7:03 
AnswerRe: how can i do this with C++ [modified] Pin
Rajkumar R1-May-08 7:10
Rajkumar R1-May-08 7:10 
GeneralRe: how can i do this with C++ Pin
Randor 1-May-08 9:14
professional Randor 1-May-08 9:14 
GeneralRe: how can i do this with C++ Pin
Maximilien1-May-08 9:24
Maximilien1-May-08 9:24 
GeneralRe: how can i do this with C++ Pin
JudyL_MD1-May-08 10:27
JudyL_MD1-May-08 10:27 
GeneralRe: how can i do this with C++ Pin
Maximilien1-May-08 10:47
Maximilien1-May-08 10:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.