Stop all downloading objects
When I close my form it automatically stops all downloads within the application.
I have a number of different objects including web services and picture boxes all simultaniously downloading different things.
How can I stop all downloads in my app, something like the stop button of internet explorer is a good example?
Something like Me.allDownloadingProcesses.Stop().
It must be possible as it occurs when the application is closed.
Re: Stop all downloading objects
Many of those objects would inbuilt ways for you to stop a download. For instance, the PictureBox has a LoadAsync method to load an Image and CancelAsync will stop it. When you exit all your objects are disposed so they cease to exist as far as the OS is concerned. You don't want to do that if your app is still running so you need to look at each individual object and determine how to cancel its operation. Often it will be just like the PictureBox: call an asynchronous method instead of the synchronous equivalent so you can cancel if and when desired.
Re: Stop all downloading objects
Quote:
Originally Posted by jmcilhinney
Many of those objects would inbuilt ways for you to stop a download. For instance, the PictureBox has a LoadAsync method to load an Image and CancelAsync will stop it. When you exit all your objects are disposed so they cease to exist as far as the OS is concerned. You don't want to do that if your app is still running so you need to look at each individual object and determine how to cancel its operation. Often it will be just like the PictureBox: call an asynchronous method instead of the synchronous equivalent so you can cancel if and when desired.
I know I can do them all individually but that is not an option, I just want to be able to stop them all at once, even if I have to dispose them.
I tried disposing multiple picture boxes but it does not stop the downloading???
I tried to cancelAsync of a list of picture boxes but there is a bug in the cancelAscnc method that kills all future loadAsync methods (Thanks Microsoft)
Surely there is some me.stopDownloads() or some method that will have this effect?