R
redear
Is there a way to immediately terminate a BackgroundWorker thread? My
problem is that the BackgroundWorker starts with a call to
My.Computer.FileSystem.GetFiles that can run for a very long time if
it is pointing to a directory tree with many files. If the user
requests cancellation during this time, the main thread can call
CancelAsync and can post a "Cancellation Pending" message to the user,
but the BackgroundWorker cannot respond to the CancellationPending
property until the call to My.Computer.FileSystem.GetFiles returns. It
seems inelegant to rewrite the call to My.Computer.FileSystem.GetFiles
to use calls to Dir or something that would allow me to poll the
CancellationPending property while I'm building the collection of file
names. And I have not wanted to rewrite the BackgroundWorker as a
standard thread (read that "go through the learning curve"!). I would
rather abort the BackgroundWorker thread but do not see how to do it.
Thanks.
redear
problem is that the BackgroundWorker starts with a call to
My.Computer.FileSystem.GetFiles that can run for a very long time if
it is pointing to a directory tree with many files. If the user
requests cancellation during this time, the main thread can call
CancelAsync and can post a "Cancellation Pending" message to the user,
but the BackgroundWorker cannot respond to the CancellationPending
property until the call to My.Computer.FileSystem.GetFiles returns. It
seems inelegant to rewrite the call to My.Computer.FileSystem.GetFiles
to use calls to Dir or something that would allow me to poll the
CancellationPending property while I'm building the collection of file
names. And I have not wanted to rewrite the BackgroundWorker as a
standard thread (read that "go through the learning curve"!). I would
rather abort the BackgroundWorker thread but do not see how to do it.
Thanks.
redear