Re: Help with user interaction with worker thread
- From: "Danny" <fernandez.dan@xxxxxxxxx>
- Date: 29 Jan 2006 20:49:37 -0800
Vipin,
Thanks for the reply. I came up with the following code with your
advice. As long the user wants to retry I will keep executing
myWorkerClass.DoCommand1.
while(view->m_executing)
{
while(1)
{
if( myWorkerClass.DoCommand1( ) != PASS)
{
::ResetEvent(view->m_cmd1RetryEvent)
::PostMessage(m_hWnd,AM_CMD1_FAILED,0,0);
::WaitForSingleObject(view->m_cmd1RetryEvent ,
INFINITE);
continue; // user wanted to retry
}
else
{
// It passed so get out of loop
break;
}
}
// command 2 is similar
}
Then in my Message handler have
LRESULT CMyView::OnCmd1Fail( WPARAM, LPARAM )
{
// I want to ask user,if they want to repeat command
int rtnCode = AfxMessageBox("Command 1 failed",
MB_RETRYCANCEL);
if(rtnCode == IDRETRY )
{
// signal to worker thread to repeat
::SetEvent(m_cmd1RetryEvent)
}
return 0;
}
This works fine if the user wants to retry, but if the user does not
want to retry. My thread will be waiting for INFINITE time.
This works fine if the user wants to retry. It will set the event to
let my worker thread know that the user wants to retry.
Danny
.
- Follow-Ups:
- Re: Help with user interaction with worker thread
- From: Joseph M . Newcomer
- Re: Help with user interaction with worker thread
- From: Vipin [MVP]
- Re: Help with user interaction with worker thread
- References:
- Help with user interaction with worker thread
- From: Danny
- Re: Help with user interaction with worker thread
- From: Vipin [MVP]
- Help with user interaction with worker thread
- Prev by Date: Re: Help with user interaction with worker thread
- Next by Date: Re: Help with user interaction with worker thread
- Previous by thread: Re: Help with user interaction with worker thread
- Next by thread: Re: Help with user interaction with worker thread
- Index(es):
Relevant Pages
|