Irfan
Irfan

Reputation: 2771

Exception forwarding from BackgroundWorker to Main Thread

What is the best way to catch Exceptions occured in BackgroundWorker in main application thread. I have intensive UPD operations being processed in BackgroundWorker, but when exception occurs, my main application can not log what happened. Please recommend the best practices.

Thanks

Upvotes: 1

Views: 681

Answers (1)

to StackOverflow
to StackOverflow

Reputation: 124706

You should handle the RunWorkerCompleted event, which will be fired on your main application thread.

RunWorkerCompletedEventArgs.Error will contain the exception, or will be null if there was no exception.

Upvotes: 3

Related Questions