Re: Question on Progress dialog
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:ff5kp39mq1049dhb4s3ahunf1d81rpvh2u@4ax.com...
Sure it does! It's the BOOL that the worker thread uses to determine if
it should shut
down, e.g.
while(!stopped)
{
...do stuff
}
then if stopped is set TRUE, this loop exits.
The BOOL would be a member of the CWinThread-derived class, or passed in
via the startup
parameters for a worker thread.
void CMyProgressDlg::OnCancel()
{
*stop = TRUE;
}
I've got code like this in several apps, and it isn't very hard to write
it.
That would work, but it's not a complete solution depending on the user flow
you want. As I wrote earlier, in some cases, when Cancel is clicked, the
worker thread must be signaled to terminate, but that could take awhile
depending on how quickly the worker thread can check the BOOL. In that
case, you want the dialog to switch to something like, "Cancel in progress,
please wait". And only when the worker thread is completely terminated do
you want the dialog to close. In that case, either the worker thread needs
to know how to destroy the progress dialog, or else the UI class that
started the worker thread and progress dialog in the first place (and thus
is the correct place to coordinate the two) needs to do it. And that's
where the callback to the UI class handles all this nicely.
-- David