jbwitt

I have a user-interface thread that creates a dialog box:


BOOL tcMyThreadClass::InitInstance()
{
  mCMyDialog = new tcMyDialog;
  m_pMainWnd = mCMyDialog;

.....

 return TRUE;
}

I want to terminate this thread (call its ExitInstance()) whenever mCMyDialog::OnCancel() is called.  But I can not get mCMyDialog to post the WM_QUIT message to this thread.  It will only post it to the main thread that created this thread.  What am I missing



Re: Visual C++ Language exiting a user-interface thread

Marius Bancila

Well, it's hard to tell without seeing the code. You should post it here.

Does the dialog have a pointer to the thread






Re: Visual C++ Language exiting a user-interface thread

jbwitt

I figured out a way around the problem. The thread no longer needs the WM_QUIT message.

thanks





Re: Visual C++ Language exiting a user-interface thread

Simple Samples

The CWinThread::ExitInstance documentation clearly states not to call it. Perhaps you mean that you want to cause it to be called. Since it is a UI thread you probably don't want to post a WM_QUIT message either.

The typical solution is (for the main thread) to create an event that the thread waits for to signal it to exit.