简体   繁体   中英

Invoke Delegate separate class progress bar

I'm loading a large amount of data from a separate project and would like to display the progress to the user.

So as each piece of data is loaded, I'd like to pass that event back from a Framework Class, back to the main winform, then to the separate dialog progress bar form.

There would be three things passed back:

  1. Status message
  2. Current status count
  3. Total Items to process.

All I need to know is how to pass this information back and where the delegates should go.

List<myObject> objListFoo = new List<myObject>();
FormLoadingProgress frmProgress = new FormLoadingProgress();
frmProgress.ShowInTaskBar = false;
frmProgress.Show();

Framework.Foo objFoo = new Framework.Foo();
objFoo.DoEvent(); // <-- This takes 10-60 seconds
objListFoo = objFoo.GetData();

frmProgress.Close();
frmProgress.Dispose();

Here's an example showing exactly what you need to do.

The only thing you need to adjust in that example is the method call to ReportProgress. In your case, you'll probably want to call this version , which receives an int and an object. In that object you can pass in whatever information you need (1. Status message, 2. Current status count, 3. Total Items to process.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM