Need a simple CRM and Project Management system?
Check out JobNimbus - CRM for Contractors and Service Professionals.
Check out JobNimbus - CRM for Contractors and Service Professionals.
Popular Articles
Last viewed:
Recent comments
- maybe this will help you alot
2 days 13 hours ago - Reply to comment - Code Samples & Tutorials
3 days 9 hours ago - thank you for sharing
5 days 5 hours ago - Great explanation and more questions
6 days 8 hours ago - Insertion of illegal Element:
5 weeks 2 days ago - Insertion of illegal Element: 32
5 weeks 2 days ago - re "But, this will NOT work."
6 weeks 2 days ago - Unable to cast COM object of t
6 weeks 2 days ago - Saved my life
6 weeks 3 days ago - nice
9 weeks 2 days ago

Catching download errors
There are a couple of ways to do this. If you attempt to download a file that does not exist (invalid URL) or that may have a connection drop/timeout, then there can be an exception thrown here.
If you want the code to prompt the user and let them retry, then put a try/catch block around the code in the background worker DoWork method. When the exception is thrown, allow them to restart the download with a dialog or other message box.
If you want to abort the operation, then you don't have to do anything because the background worker already handles exception packaging across threads for you. Just let the exception get thrown. Then in the background worker RunWorkerCompleted() method, you can get the result by checking the "e" RunWorkerCompletedEventArgs parameter. Check if the Error property is = null or not. If it is not null, then there will be the exception which you can display to the user there.