void Target_ExecuteCommand(object parameter) { if (Enabled) { parameter = Parameter ?? parameter; var isAsyncCommand = Command is IAsyncCommand; BeforeExecuteAction?.Invoke(this); if (!isAsyncCommand) { CommandStarted?.Invoke(this); } try { Command.Execute(parameter); } finally { AfterExecuteAction?.Invoke(this); if (!isAsyncCommand) { CommandFinished?.Invoke(this); } } } }
protected virtual void OnCommandFinished() { if (CommandFinished != null) { CommandFinished.Invoke(); } }
public void Terminate(bool?result = null) { if (IsRunning) { _isFinishedByTerminate = true; if (result != null) { Result = (bool)result; } Finish(); CommandFinished.SafeRaise(this); } }
void AsyncCommand_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { var command = (IAsyncCommand)sender; if (e.PropertyName == "IsRunning") { if (command.IsRunning) { CommandStarted?.Invoke(this); } else { CommandFinished?.Invoke(this); } } }
private void OnCommandFinished(Command cmd) { CommandFinished?.Invoke(this, cmd); }
/// <summary> /// Method called each time a command has finished. Calls the CommandFinished event with the finished command as sender argument. /// </summary> /// <param name="cmd">The command that was successfully executed.</param> internal static void OnCommandFinished(Command cmd) { Counter.IncrementRamAccesses(); //for each command we actually need to access the RAM CommandFinished?.Invoke(cmd, new EventArgs()); }