public static ResultCIDWait Show(Func <Task> action, string message) { ResultCIDWait resultCIDWait = new ResultCIDWait(); _FrmEspere = new FrmWait(action, message); resultCIDWait.IsCompleted = (_FrmEspere.ShowDialog() == System.Windows.Forms.DialogResult.OK); if (!resultCIDWait.IsCompleted) { resultCIDWait.ExceptionsList = _FrmEspere.Exceptions; } _FrmEspere.Dispose(); return(resultCIDWait); }
/// <summary> /// 窗口关闭事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> static void WaitForm_FormClosed(object sender, FormClosedEventArgs e) { if (mWaiting || !(sender is FrmWait)) { //信号等待中被异常关闭,或主窗口被关闭时自动通知信号复位 mEvents.Set(); return; } mShowing = false; //回收等待窗口 try { mWait.Dispose(); } finally { mWait = null; } }