/// <summary> /// Don't use semaphore /// </summary> /// <param name="name"></param> /// <param name="undo"></param> /// <param name="undoParams"></param> /// <param name="redo"></param> /// <param name="redoParams"></param> /// <returns></returns> public UndoRedoWithParametersCommand NewCommand(string name, Action <object[]> undo, object[] undoParams, Action <object[]> redo, object[] redoParams) { var command = new UndoRedoWithParametersCommand(undo, undoParams, redo, redoParams, Guid.NewGuid().ToString(), name); //UndoRedoDropoutStack.LastCommandAdded = command; _UndoCommands.Push(command); _RedoCommands.Clear(); return(command); }
/// <summary> /// Use semaphore.WaitAsync /// </summary> /// <param name="name"></param> /// <param name="undo"></param> /// <param name="undoParams"></param> /// <param name="redo"></param> /// <param name="redoParams"></param> /// <returns></returns> public async Task <UndoRedoWithParametersCommand> NewAsyncCommandAsync(string name, Func <object[], Task> undo, object[] undoParams, Func <object[], Task> redo, object[] redoParams) { var token = _CTS.Token; await _Semaphore.WaitAsync(); if (token.IsCancellationRequested) { return(null); } var command = new UndoRedoWithParametersCommand(undo, undoParams, redo, redoParams, Guid.NewGuid().ToString(), name); //UndoRedoDropoutStack.LastCommandAdded = command; if (token.IsCancellationRequested) { return(null); } _UndoCommands.Push(command); _RedoCommands.Clear(); _Semaphore.Release(); return(command); }