/// <summary> /// Closes the Task dialog, and clears the Cancelled event handle subscriptions /// </summary> public static void CloseForm() { // No exception here if (Instance == null || Instance.IsDisposed) { return; } // Remove all cancellation subs if (Cancelled != null) { Cancelled = (CancelEventHandler)Delegate.RemoveAll(Cancelled, Cancelled); } try { Instance.Invoke((Action) delegate() { Instance.Close(); Instance = null; }); } catch { } }