T
Tom P.
I have an application that uses a BackgroundWorker to get a list of
files. The user can navigate away from this to a different directory
so there needs to be a way to interrupt the BackgroundWorker and
restart with a different base path.
The problem I have is if I check IsBusy and call CancelAsync() and
wait for the backgroundWorker the wait loop is too tight for the
BackgroundWorker to communicate with the UI thread (unless I use
DoEvents). If I don't check IsBusy, just call CancelAsync and restart
the process the UI thread gets the cancel flag set after the second
DoWork call and the BackgroundWorker is never able to start the second
process.
Any ideas on how to reuse a BackgroundWorker?
Thanks,
Tom P.
files. The user can navigate away from this to a different directory
so there needs to be a way to interrupt the BackgroundWorker and
restart with a different base path.
The problem I have is if I check IsBusy and call CancelAsync() and
wait for the backgroundWorker the wait loop is too tight for the
BackgroundWorker to communicate with the UI thread (unless I use
DoEvents). If I don't check IsBusy, just call CancelAsync and restart
the process the UI thread gets the cancel flag set after the second
DoWork call and the BackgroundWorker is never able to start the second
process.
Any ideas on how to reuse a BackgroundWorker?
Thanks,
Tom P.