// ProgressEventArgs constructor public ProgressEventArgs(Object progressItem, int progressPosition, ProgressEvents progressEvent, Exception exception) { this.ProgressItem = progressItem; this.ProgressPosition = progressPosition; this.ProgressEvent = progressEvent; this.Exception = exception; }
/// <summary> /// Handles the reporting of the job state /// </summary> /// <param name="progressType"></param> /// <param name="progressValue"></param> /// <param name="image"></param> private void ReportProgress(ProgressEvents progressType, int progressValue, string patientNumber) { // Thread safe update of controls if (messageTextBox.InvokeRequired) { // re-call on the UI thread of this control Invoke(new ProgressCallback(ReportProgress), progressType, progressValue, patientNumber); } else { switch (progressType) { case ProgressEvents.ProcessedItem: { progressBar.Value = progressValue; processedTextBox.Text = progressValue.ToString(); } break; case ProgressEvents.Cancelled: { MessageBox.Show(string.Format("The job was cancelled.\r\nSample images were added to {0} patients.", progressValue) , "Cancelled", MessageBoxButtons.OK, MessageBoxIcon.Warning); EndJob(); } break; case ProgressEvents.Completed: { if (badItems.Count > 0) { MessageBox.Show("Some images failed to save" , "Image Errors Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { MessageBox.Show(string.Format("Sample images were added to {0} patients", progressValue), "Complete" , MessageBoxButtons.OK, MessageBoxIcon.Information); } EndJob(); } break; case ProgressEvents.ErrorOccurred: { badItems.Add(patientNumber); messageTextBox.Text = string.Format("Error occurred, image batch was not saved, ({0})", patientNumber); } break; } Application.DoEvents(); } }
/// <summary> /// Trigger any progress event handlers /// </summary> /// <param name="patientNumber">Current patient number being processed</param> /// <param name="progressType">The nature of processing event</param> /// <param name="progressPosition">The current position in the processing list</param> private void RaiseProgress(string patientNumber, ProgressEvents progressType, int progressPosition) { if (Progress != null) { Progress(this, new ProgressEventArgs(patientNumber, progressPosition, progressType)); } }
// ProgressEventArgs constructor public ProgressEventArgs(Object progressItem, int progressPosition, ProgressEvents progressEvent) { this.ProgressItem = progressItem; this.ProgressPosition = progressPosition; this.ProgressEvent = progressEvent; }