Throwing an exception from a BackgroundWorker which calls an async. method (Webrequest)
Posted
by mrbamboo
on Stack Overflow
See other posts from Stack Overflow
or by mrbamboo
Published on 2010-04-09T16:49:04Z
Indexed on
2010/04/09
16:53 UTC
Read the original article
Hit count: 469
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.
© Stack Overflow or respective owner