Reply to comment

cancellation

this is a little late, but here's my two cents!

you need to set the 'WorkerSupportsCancellation' property of the background worker to true, then implement some sort of button that will call the 'CancelAsync' method of the background worker, this sets the 'CancellationPending' property of the background worker to true. you then need to implement some sort of check to catch the change (if statements work well) and cancel the background worker there using the event arguments (in most cases, e.cancel works. remember to close any streams you have open! i think, but i'm not 100% sure, that if you implement the check inside a while loop you also need a break statement)

hope that helps! might be an easier way of doing it, but this works well for me. only been using c# for a few months, be happy to hear any better ways if there are any!

cracking article btw, i adapted this code for an ftp uploader and it worked a treat!

Reply