Is there a way to immediately terminate a BackgroundWorke r thread? My
problem is that the BackgroundWorke r starts with a call to
My.Computer.Fil eSystem.GetFile s 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 "Cancellati on Pending" message to the user,
but the BackgroundWorke r cannot respond to the CancellationPen ding
property until the call to My.Computer.Fil eSystem.GetFile s returns. It
seems inelegant to rewrite the call to My.Computer.Fil eSystem.GetFile s
to use calls to Dir or something that would allow me to poll the
CancellationPen ding property while I'm building the collection of file
names. And I have not wanted to rewrite the BackgroundWorke r as a
standard thread (read that "go through the learning curve"!). I would
rather abort the BackgroundWorke r thread but do not see how to do it.
Thanks.
redear
problem is that the BackgroundWorke r starts with a call to
My.Computer.Fil eSystem.GetFile s 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 "Cancellati on Pending" message to the user,
but the BackgroundWorke r cannot respond to the CancellationPen ding
property until the call to My.Computer.Fil eSystem.GetFile s returns. It
seems inelegant to rewrite the call to My.Computer.Fil eSystem.GetFile s
to use calls to Dir or something that would allow me to poll the
CancellationPen ding property while I'm building the collection of file
names. And I have not wanted to rewrite the BackgroundWorke r as a
standard thread (read that "go through the learning curve"!). I would
rather abort the BackgroundWorke r thread but do not see how to do it.
Thanks.
redear
Comment