Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# BackgroundWorker ReportProgress Int32?

Tags:

c#

I want to display progress from a BackgroundWorker to a ProgressBar in the UI. What I dont understand is why the BackgroundWorker's ReportProgress function takes an Int32 when the ProgressBar can take a double value for progress. My process is very intricate and I need to make decimal progress updates. It doesnt help if I have to keep adjusting everything to the nearest integer. Can anyone suggest someway i can work around this?

like image 744
Aks Avatar asked Sep 24 '26 15:09

Aks


1 Answers

The ProgressChangedEventArgs Class can take an optional UserState value. You can pass anything you want to this (including for example a double value). Set it with the ReportProgress method

like image 111
Simon Mourier Avatar answered Sep 26 '26 05:09

Simon Mourier



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!