示例#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);
                    }
                }
            }
        }
        private void Worker(object parameter)
        {
            try
            {
                Setup();

                while (_actions.Count > 0)
                {
                    ICommand command = _actions.Peek();
                    CommandStarted?.Invoke(this, new CommandProgressEventArgs(command));

                    command.Execute(null);

                    lock (_actions)
                    {
                        _processed++;
                        _actions.Dequeue();
                    }

                    CommandEnded?.Invoke(this, new CommandProgressEventArgs(command));
                }
            }
            finally
            {
                TearDown();
            }
        }
示例#3
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);
                }
            }
        }
示例#4
0
 protected void OnCommandStarted(string arguments)
 {
     CommandStarted?.Invoke(this, new NpmCommandStartedEventArgs(arguments));
 }