Throwing an exception from a BackgroundWorker which calls an async. method (Webrequest)
- by mrbamboo
Hi,
My main application creates a new BackgroundWorker X
the DoWork event handler of X calls a method Y of my controller. This method creates the WebRequest (async.) instance and the callback using AsyncCallback.
When the response arrives the callback method Z gets called and the content will be analyzed. It can happen that the response has an unwanted content. At that moment callback Z will throw an exception.
I want to catch this exception in my main application.
I tried it in DoWork and RunWorkerCompleted but nothing can be caught from there.
Error in RunWorkerCompletedEventArgs is always null.