/// <summary> /// Unexecutes the command in a spawned thread. /// </summary> /// <param name="command">The command.</param> private void UnExecuteInSpawnedThread(AbstractCommand command) { command.CancellationTokenSource = new CancellationTokenSource(); Task.Factory .StartNew(command.UnExecute); }
public void RecordCommand(AbstractCommand command) { if (command == null) { throw new ArgumentException("Command needs to be of type AbstractCommand", "command"); } if (unboundedTransactionRunning && !unboundedTransactionCall) { throw new InvalidOperationException("An unbound transaction is currently running. Before executing a regular command you need to either commit or rollback the " + "current transaction. Also you can add more commands to the current transaction via CommandManager.RunWithinTransaction()."); } if (CurrentTransaction == null) { CurrentTransaction = new TransactionalCommand(); this.UndoStack.Push(CurrentTransaction); } CurrentTransaction.AddCommand(command); if (command.ExecutionConfiguration.RunInBackground) { this.ExecuteInSpawnedThread(command); } else { command.Execute(); } }
/// <summary> /// Adds a new command to the internal collection. /// </summary> /// <param name="command">The command.</param> public void AddCommand(AbstractCommand command) { this.Commands.Add(command); }