Re: Help with user interaction with worker thread

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



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

.



Relevant Pages

  • installing kernel-image
    ... while executing a: ... Then I retry and I've got this output: ... subprocess post-installation script returned error ... proceed with another package installation! ...
    (Debian-User)
  • Re: Jakartas Latest HttpClient
    ... does NOT retry after the first fail. ... I'll take your advice and try the ... Prev by Date: ...
    (comp.lang.java.programmer)