I have a WinForms app written in C# with .NET 3.5. It runs a lengthy batch process. I want the app to update status of what the batch process is doing. What is the best way to update the UI?
Use Backgroundworker
, and if you are also trying to update the GUI thread by handling the ProgressChanged
event(like, for a ProgressBar
), be sure to also set WorkerReportsProgress=true
, or the thread that is reporting progress will die the first time it tries to call ReportProgress
...
an exception is thrown, but you might not see it unless you have 'when thrown' enabled, and the output will just show that the thread exited.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With