/// <summary> /// Call this static method to start a time-consuming operation involving user interface (the operation may access form controls). The user is notified through "Please wait..." window. /// </summary> public static void StartUIOperation(Control parent, LongOperationEventHandler operation) { LongOperation dlg = new LongOperation(parent, operation); dlg.ShowDialog(); if (dlg.longOperationException != null) { throw dlg.longOperationException; } }
/// <summary> /// Call this static method to start a time-consuming operation that DOES NOT involve user interface (the operation may NOT access form controls). /// For example, you may call this method to execute an entity adapter method that takes several seconds to complete. /// The user is notified through "Please wait..." window. /// </summary> public static void StartNonUIOperation(LongOperationEventHandler operation) { LongOperation dlg = new LongOperation(null, operation); dlg.ShowDialog(); if (dlg.longOperationException != null) { throw new Exception(null, dlg.longOperationException); } }
private void BtnAnalyze_Click(object sender, EventArgs e) { LongOperation.StartNonUIOperation(delegate { validateModel.PerformValidation(); }); LoadGridViews(); validateModel.CheckValidados(); }