public void Test(int reportCount) { try { for (int i = 0; i < reportCount; i++) { //DO somthing.... //PostReportWorkStatus("当前进度:", i); WorkProcessingEventArgs e = new WorkProcessingEventArgs(i.ToString(), reportCount, i, base.ProcessTime, base.UserState); e.Data = DateTime.Now; base.InvokeEvent<WorkProcessingEventArgs>(this.OnTestKey, e); //OnTest(this, e); System.Threading.Thread.Sleep(1000); } } catch (Exception ex) { BusinessExceptionHandler.HandlerException("Test error!", ex); } }
void businessDemo_OnReportWorkStatus(object sender, WorkProcessingEventArgs e) { try { if (e.Data == null) return; int index = Convert.ToInt32(e.Data); label1.Text = e.WorkStatus + index.ToString(); } catch (Exception ex) { UserInterfaceExceptionHandler.HandlerException( "UIProcess error!", ref ex); } }
void businessDemo_OnTest2(object sender, WorkProcessingEventArgs e) { Console.WriteLine(e.WorkStatus + "---" + e.Data.ToString()); label2.Text = e.WorkStatus; }