Help with user interaction with worker thread
- From: "Danny" <fernandez.dan@xxxxxxxxx>
- Date: 29 Jan 2006 14:37:30 -0800
Hi,
My question is that I have a simple worker thread that repeats the same
two network commands, pretty straight forward. My trouble is when a
command fails I want to ask the user if they want to repeat the command
again. Here is a stripped down example that I want to do
UINT CMyView::MyThread(LPVOID p)
{
(CMyView*) view = (CMyView*) p;
view->Run();
return 0;
}
void CMyView::Run()
{
while(m_executing)
{
if( myWorkerClass.DoCommand1( ) != PASS)
{
::PostMessage(m_hWnd,AM_CMD1_FAILED,0,0);
}
if( myWorkerClass.DoCommand2() != PASS)
{
::PostMessage(m_hWnd,AM_CMD1_FAILED,0,0);
}
}
}
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 )
{
// user wants to retry command
}
return 0;
}
LRESULT CMyView::OnCmd2Fail( WPARAM, LPARAM )
{
// I want to ask user,if they want to repeat command
int rtnCode = AfxMessageBox("Command 2 failed", MB_RETRYCANCEL);
if(rtnCode == IDRETRY )
{
// user wants to retry command
}
return 0;
}
So for example if myWorkerClass.DoCommand1 fails I post a command1 fail
messge. Then I ask the user if they want to repeat this command again
at the message handler. This is the part I'm stuck at, how do I connect
the two with the retry and my thread.
I appreciate any feedback, thanks
Danny.
.
- Follow-Ups:
- Re: Help with user interaction with worker thread
- From: Vipin [MVP]
- Re: Help with user interaction with worker thread
- Prev by Date: Converting ascii to hex
- Next by Date: Re: Terminating
- Previous by thread: Converting ascii to hex
- Next by thread: Re: Help with user interaction with worker thread
- Index(es):
Relevant Pages
|
|