protected virtual void OnCompleted(WorkItemCompletedEventArgs Args) { //raise the Completed event in the context of the form EventHandler <WorkItemCompletedEventArgs> temp = Completed; if (temp != null) { temp.Invoke(this, Args); } }
//handler method to run when work has completed private void WorkThread_Completed(object sender, WorkItemCompletedEventArgs e) { lvMain.Items[int.Parse(e.Result.ItemID)].SubItems[1].Text = e.Result.ResultCode; if (e.Result.ResultCode == "ERR") { lvMain.Items[int.Parse(e.Result.ItemID)].SubItems[2].Text = e.Result.Message; } RunningThreadCount--; UpdateThreadCount(); if (RunningThreadCount == 0) { CleanUp(); } }