/// <summary> /// Execs the async. /// </summary> /// <param name="state">The state.</param> private void ExecAsync(object state) { ModuleProc PROC = new ModuleProc("AsyncDialogForm", "ExecAsync"); DialogResult result = DialogResult.None; try { if (_callback != null) { _callback(this); } if (this.ExecutorService != null) { result = this.ExecutorService.IsShutdown ? DialogResult.Cancel : DialogResult.OK; } else { result = DialogResult.OK; } } catch (ThreadAbortException ex) { result = DialogResult.Abort; Log.Exception(PROC, ex); if (_abortCallback != null) { _abortCallback(this); } } catch (Exception ex) { Log.Exception(PROC, ex); result = DialogResult.Ignore; } finally { try { _elapsedTimer.Stop(); if (result != DialogResult.Abort) { if (_finishedCallback != null) { _finishedCallback(this); } } this.CrossThreadInvoke(new Action(() => { if (this.CloseOnComplete) { if (!this.IsDisposed) { this.Close(); } } else { this.EnableOKButton(); } }), null); } catch { } finally { this.DialogResult = result; } } }