Hello,
My main thread does some computation indefinetly. To stop the computation, I created a thread that displays a message box, and when pressed, sets a global variable that stops the main program loop. However, my program just hangs when I get the start the thread. The message box does not show up either. Here's the code:
Thanks.Code:static bool keep_sending; static UINT thread_func(LPVOID pParam) { AfxMessageBox("Please OK to stop"); keep_sending = false return 0; } void A::func(void) { CWinThread *pthread; keep_sending = false; if(some_condition) { keep_sending = true; pthread = AfxBeginThread(thread_func, NULL, THREAD_PRIORITY_NORMAL); } do { // do some stuff }while(keep_sending); }