Re: Help with user interaction with worker thread

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Mon, 30 Jan 2006 09:26:42 +0530, "Vipin [MVP]" <Vipin@xxxxxxxxxx> wrote:

>You should use events in this situation:-
>
>if( myWorkerClass.DoCommand1( ) != PASS)
> {
> HANDLE hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
> ::PostMessage(m_hWnd,AM_CMD1_FAILED,0,0);
> WaitForSingleObject(hEvent , INFINITE);
> CloseEvent(hEvent);
> }
>
>What I would do is then package the hEvent in the parameter passed in to the
>GUI thread, in your case if it is "view".
>I would do view->m_hEvent = hEvent; after creating the event or package this
>in the wParam or lParam
>of the PostMessage.
>
>Then in the GUI thread after the user has been prompted and shown the
>MessageBox, when he click "ok"
>Set the event to signaled state, so the worker thread can continue from that
>point.

It would be simpler just to use SendMessage...

--
Doug Harrison
Visual C++ MVP
.