private void OnTaskCompletedEvent(bool result) { TaskCompletedEventHandler handler = TaskCompletedEvent; if (handler != null) { handler(this, result); } }
/// <summary> /// Raised Task Completed, when the thread is done after the UI returns to normal. /// </summary> /// <param name="propertyName">The property that has a new value.</param> public void OnTaskCompleted(bool failed, object state, string message) { TaskCompletedEventHandler handler = this.TaskCompleted; if (handler != null) { var e = new TaskCompletedEventArgs() { Failed = failed, State = state, Message = message }; handler(this, e); } }
public static Task RemoveTaskCompletedEventHandlerAsync(this IDataBase dataBase, TaskCompletedEventHandler handler) { return(dataBase.Dispatcher.InvokeAsync(() => dataBase.TaskCompleted -= handler)); }
public static Task AddTaskCompletedEventHandlerAsync(this IUserContext userContext, TaskCompletedEventHandler handler) { return(userContext.Dispatcher.InvokeAsync(() => userContext.TaskCompleted += handler)); }
/// <summary> /// Always runs the specified action in the UI thread after the main <see cref="DoWork"/> action runs /// and after the <see cref="Succeed"/> or <see cref="Fail"/> callbacks have ran, regardless of /// whether the main <c>DoWork</c> action succeeded or failed. /// </summary> /// <param name="finally">Action to run in the UI thread</param> /// <returns>Reference to this <c>TaskBuilder</c></returns> public TaskBuilder Finally(TaskCompletedEventHandler @finally) { _finally = @finally; return(this); }
/// <summary> /// Always runs the specified action in the UI thread after the main <see cref="DoWork"/> action runs /// and after the <see cref="Succeed"/> or <see cref="Fail"/> callbacks have ran, regardless of /// whether the main <c>DoWork</c> action succeeded or failed. /// </summary> /// <param name="finally">Action to run in the UI thread</param> /// <returns>Reference to this <c>TaskBuilder</c></returns> public TaskBuilder Finally(TaskCompletedEventHandler @finally) { _finally = @finally; return this; }