public static object ShowWindow(Func<object, object> method, object param, string message, bool showProgress) { if (_is_busy) return null; if (_presentedDialog == null || _presentedDialog.IsDisposed) _presentedDialog = new frmLoadingDialog(); _is_busy = true; _current_execution_return_detail = null; var t = new Thread(delegate(object o) { _current_execution_return_detail = method(o); _is_busy = false; try { _presentedDialog.Invoke(new Action<object>(objectPassed => HideWindow()), new object[]{null}); } catch (Exception ex) { Console.WriteLine(ex.Message); } }); _message = message; _cancel = false; _presentedDialog.SetUp(showProgress); t.SetApartmentState(ApartmentState.STA); t.Start(param); if (_is_busy) { _presentedDialog.ShowDialog(); } return _current_execution_return_detail; }
public static void ShowWindow(string message) { if (_presentedDialog == null || _presentedDialog.IsDisposed) _presentedDialog = new frmLoadingDialog(); _message = message; _cancel = false; _presentedDialog.SetUp(false); _presentedDialog.Show(); }