Hello
I'm implementing a MFC S/W and it has two buttons to create a thread to log data and cancel it.
When a button "start" is clicked, it supposed to create a thread by
hThread_log = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)LogData_thr, this, NULL, &thrId_log);
The function LogData_thr has while(1) in it.
And when a button "stop" is clicked, it supposed to stop the thread.
I tried TerminateThread() with CloseHandle() and some flag variable which breaks the infinite loop in the function LogData_thr.
However, every trial caused a problem when I put "start" button after stopping the thread (after the function is returned).
Something unwanted happens inside the function LogData_thr.
How can I manipulate the thread?
I always appreciate your help you have given to me.