private void invokeLogin() { WaitingForm.InvokeWithWaitingForm("Logowanie...", (Action) delegate() { try { loginSuccess = wfs.loginToWFSWithUserInfo(login, haslo); } catch (Exception ex) { ExceptionManager.LogError(ex, Logger.Instance, true); loginSuccess = false; } }); }
public static void InvokeWithWaitingForm(string formName, Action action) { WaitingForm waiting = new WaitingForm(formName); Thread thr = new Thread((ThreadStart) delegate() { action(); waiting.Invoke((MethodInvoker) delegate() { if (!waiting.IsDisposed) { waiting.Dispose(); } }); }); thr.IsBackground = true; thr.Start(); if (!waiting.IsDisposed) { waiting.ShowDialog(); } }