Click here to Skip to main content
15,893,190 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to Kill the Worker Thread ? Pin
Cedric Moonen14-Apr-09 0:06
Cedric Moonen14-Apr-09 0:06 
GeneralRe: How to Kill the Worker Thread ? PinPopular
Cedric Moonen14-Apr-09 0:05
Cedric Moonen14-Apr-09 0:05 
GeneralRe: How to Kill the Worker Thread ? Pin
Suresh H14-Apr-09 0:37
Suresh H14-Apr-09 0:37 
GeneralRe: How to Kill the Worker Thread ? Pin
Cedric Moonen14-Apr-09 0:48
Cedric Moonen14-Apr-09 0:48 
GeneralRe: How to Kill the Worker Thread ? Pin
Rajesh R Subramanian14-Apr-09 1:11
professionalRajesh R Subramanian14-Apr-09 1:11 
GeneralRe: How to Kill the Worker Thread ? Pin
Cedric Moonen14-Apr-09 1:32
Cedric Moonen14-Apr-09 1:32 
GeneralRe: How to Kill the Worker Thread ? Pin
Rajesh R Subramanian14-Apr-09 1:43
professionalRajesh R Subramanian14-Apr-09 1:43 
GeneralRe: How to Kill the Worker Thread ? [modified] Pin
ParagPatel14-Apr-09 0:27
ParagPatel14-Apr-09 0:27 
Can you paste your code snap here?

You can also use flag mechanism, its good solution.

//globle variable
HANDLE hr1,hr2;
bool stopTh; //default set to false.



void CThreadDemoDlg::OnStart() 
{
	// TODO: Add your control notification handler code here

	stopTh = false;

	hr1 = CreateThread(NULL,0,(unsigned long (__stdcall *)(void *))WorkerThreadOne,this,0,0);
	hr2 = CreateThread(NULL,0,(unsigned long (__stdcall *)(void *))WorkerThreadTwo,this,0,0);
}
void CThreadDemoDlg::OnEnd() 
{
	// TODO: Add your control notification handler code here

	stopTh = true;
}

UINT WorkerThreadOne(LPVOID Param)
{
	fstream OutFile;
	OutFile.open("FileOne.txt",ios::out);

	for(int i=0;i<10000;i++)
	{
		if(stopTh == true)
			break;
		OutFile  << i << " ";
	}
	OutFile.close();
	return true;
}



Why 1.0/5.0?

Parag Patel

modified on Thursday, April 16, 2009 9:40 AM

GeneralRe: How to Kill the Worker Thread ? Pin
David Crow14-Apr-09 3:02
David Crow14-Apr-09 3:02 
GeneralRe: How to Kill the Worker Thread ? Pin
ParagPatel14-Apr-09 3:56
ParagPatel14-Apr-09 3:56 
GeneralRe: How to Kill the Worker Thread ? Pin
David Crow14-Apr-09 3:58
David Crow14-Apr-09 3:58 
GeneralRe: How to Kill the Worker Thread ? Pin
Rajesh R Subramanian14-Apr-09 4:28
professionalRajesh R Subramanian14-Apr-09 4:28 
AnswerRe: How to Kill the Worker Thread ? Pin
Hamid_RT13-Apr-09 23:40
Hamid_RT13-Apr-09 23:40 
AnswerRe: How to Kill the Worker Thread ? Pin
David Crow14-Apr-09 2:55
David Crow14-Apr-09 2:55 
Questionusing database in project Pin
sunny_vc13-Apr-09 22:51
sunny_vc13-Apr-09 22:51 
AnswerRe: using database in project Pin
_AnsHUMAN_ 13-Apr-09 22:57
_AnsHUMAN_ 13-Apr-09 22:57 
QuestionHow to update the title bar of a window with C & Win32 APIs only? Pin
mr2_9313-Apr-09 22:48
mr2_9313-Apr-09 22:48 
AnswerRe: How to update the title bar of a window with C & Win32 APIs only? Pin
Hamid_RT13-Apr-09 23:46
Hamid_RT13-Apr-09 23:46 
GeneralRe: How to update the title bar of a window with C & Win32 APIs only? Pin
mr2_9313-Apr-09 23:59
mr2_9313-Apr-09 23:59 
QuestionThe background window of CMainFrame Pin
prithaa13-Apr-09 22:29
prithaa13-Apr-09 22:29 
AnswerRe: The background window of CMainFrame Pin
Iain Clarke, Warrior Programmer14-Apr-09 3:38
Iain Clarke, Warrior Programmer14-Apr-09 3:38 
GeneralRe: The background window of CMainFrame Pin
prithaa14-Apr-09 17:44
prithaa14-Apr-09 17:44 
GeneralRe: The background window of CMainFrame Pin
Iain Clarke, Warrior Programmer14-Apr-09 21:46
Iain Clarke, Warrior Programmer14-Apr-09 21:46 
GeneralRe: The background window of CMainFrame Pin
prithaa14-Apr-09 23:11
prithaa14-Apr-09 23:11 
QuestionHow to add Event handler to dynamically created Button Pin
hemlat13-Apr-09 21:34
hemlat13-Apr-09 21:34 

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.