protected virtual async Task BuildCommandBody(IAsyncCommand command) { await ExceptionGuard.Guard(this, async() => { if (ShouldNotifyAboutLongOperation) { NotifyAboutLongOperationStarted(); } CommandBeingExecuted = true; while (InvokeBeforeCommandExecutedTaskQueue.Count > 0) { await Task.Run(InvokeBeforeCommandExecutedTaskQueue.Dequeue()); } command.RaiseCanExecuteChanged(); await ExecuteCommandAction(); }, async() => { if (ShouldNotifyAboutLongOperation) { NotifyAboutLongOperationFinished(); } CommandBeingExecuted = false; command.RaiseCanExecuteChanged(); Finally(); while (InvokeAfterCommandExecutedTaskQueue.Count > 0) { await Task.Run(InvokeAfterCommandExecutedTaskQueue.Dequeue()); } } ); }
public IAsyncGuardedCommandBuilder EnqueueBeforeCommandExecuted(Action taskToInvoke) { InvokeBeforeCommandExecutedTaskQueue.Enqueue(taskToInvoke); return(this); }