c# - How can I prevent visual studio from poping up when my BackgroundWorker throws an error -
when debugging application see messages time:
an exception of type 'xxxx.xxxxx' occurred in xxxxx.exe not handled in user code.
the problem have backgroundworkers throw exceptions in dowork, these handled checking runworkercompletedeventargs.error in runworkercompleted event - , works great @ runtime.
is there way prevent visual studio showing these "unhandled"?
is not correct way return errors dowork ui?
i tried making exception extend applicationexception , unticking box next applicationexception in exceptions dialog still shows up.
you need catch , handle exceptions inside methods dowork method calls. recommendation catch exception , use reportprogress event report interface smooth handling/notification. don't ever want "swallow" exception, reporting allow gracefully log exception or notify user in less intrusive manner.
keep in mind, you'll need to use overload of reportprogress allows use of custom userstate can either report proper progress or attach full exception.
Comments
Post a Comment