private void tvWorkitems_Expanded(object sender, TreeViewAdvEventArgs e) { if (!IsHandleCreated) { return; } Invoke(new Action(() => waitCursor.Hide())); }
public void Run(Action task, Action onComplete, Action <Exception> onError = null) { worker.DoWork += (sender, e) => task.Invoke(); worker.RunWorkerCompleted += (sender, e) => { if (e.Error != null && onError != null) { onError.Invoke(e.Error); } onComplete.Invoke(); waitCursor.Hide(); }; waitCursor.Show(); worker.RunWorkerAsync(); }
/// <summary> /// This is synchronous projection of <see cref="BackgroundTaskRunner.Run"/> /// </summary> public void Run(Action task, Action onComplete, Action <Exception> onError = null) { waitCursor.Show(); Exception exception = null; try { task.Invoke(); } catch (Exception ex) { exception = ex; } if (onError != null && exception != null) { onError.Invoke(exception); } onComplete.Invoke(); waitCursor.Hide(); }