开发者

Invoke Delegate separate class progress bar

开发者 https://www.devze.com 2023-04-01 06:58 出处:网络
I\'m loading a large amount of data from a separate project and would like to display the progress to the user.

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();

Framewo开发者_StackOverflow中文版rk.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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号