Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

BackgroundWorker still needs to call Invoke?

In the last question Display progress bar while doing some work in C#?, people has recommend use of BackgroundWorker. I thought in BackgroundWorker DoWork method you can update the GUI directly, but why this function call need to be called using Invoke.

toolTip.SetToolTip(button, toolTipText);
like image 400
Priyank Bolia Avatar asked Nov 19 '25 09:11

Priyank Bolia


1 Answers

The RunWorkerCompleted callback is marshalled onto the UI thread; DoWork is not.

You should use the ReportProgress method to update the UI during DoWork processing.

See: How to: Run an Operation in the Background

like image 71
Mitch Wheat Avatar answered Nov 22 '25 00:11

Mitch Wheat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!