public TimedNotification(string text, Action <TimedNotification> remove, IDispatcher dispatcher) { Text = text; Task.Delay(3000).ContinueWith(_ => { dispatcher.ExecuteSynchronized(() => remove(this)); }); }
/// <summary> /// Continue in dispatcher, which is also responsible for catching errors. /// </summary> internal static void ContinueInDispatcher <T>(this Task <T> task, IDispatcher dispatcher, Action <Func <T> > continuation) { task.ContinueWith((taskResult, _) => { dispatcher.ExecuteSynchronized(() => { continuation(() => taskResult.Result); }); }, null); }
protected void OnExited() { _dispatcher.ExecuteSynchronized(() => { Exited?.Invoke(); }); }