Ejemplo n.º 1
0
        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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 protected virtual void OnCommandFinished()
 {
     if (CommandFinished != null)
     {
         CommandFinished.Invoke();
     }
 }
Ejemplo n.º 3
0
 public void Terminate(bool?result = null)
 {
     if (IsRunning)
     {
         _isFinishedByTerminate = true;
         if (result != null)
         {
             Result = (bool)result;
         }
         Finish();
         CommandFinished.SafeRaise(this);
     }
 }
Ejemplo n.º 4
0
        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);
                }
            }
        }
Ejemplo n.º 5
0
 private void OnCommandFinished(Command cmd)
 {
     CommandFinished?.Invoke(this, cmd);
 }
Ejemplo n.º 6
0
 /// <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());
 }