protected virtual void OnCompleted(WorkItemCompletedEventArgs e) { //raise the Completed event ***on the form's synchronisation context*** EventHandler <WorkItemCompletedEventArgs> temp = this.Completed; if (temp != null) { temp.Invoke(this, e); } }
//handler method to run when work has completed private void item_Completed(object sender, WorkItemCompletedEventArgs e) { //GUI is free to update itself this.Result = e.Result; }