/// <summary> /// Don't use semaphore. If commands have correct RedoAction, does RedoAction. Else do Task.Run(AsyncRedoAction) /// </summary> /// <param name="lastCommand"></param> public void RedoCommandsUntil(aUndoRedoCommandBase lastCommand) { aUndoRedoCommandBase currentCommand; while ((currentCommand = RedoNextAndReturnCommand()) != null && !currentCommand.Equals(lastCommand)) { ; } }
/// <summary> /// Use semaphore.WaitAsync. If command has correct AsyncUndoAction, does AsyncUndoAction. Else do Task.Run(UndoAction) /// </summary> /// <param name="lastCommand"></param> /// <returns></returns> public async Task UndoCommandsUntilAsync(aUndoRedoCommandBase lastCommand) { aUndoRedoCommandBase currentCommand; var token = _CTS.Token; while ((currentCommand = await UndoNextAndReturnCommandAsync()) != null && !currentCommand.Equals(lastCommand)) { if (token.IsCancellationRequested) { return; } } }
/// <summary> /// Don't use semaphore. If commands have correct UndoAction, does UndoAction. Else do Task.Run(AsyncUndoAction) /// </summary> /// <param name="lastCommand"></param> public void UndoCommandsUntil(aUndoRedoCommandBase lastCommand) { aUndoRedoCommandBase currentCommand; while (true) { currentCommand = UndoNextAndReturnCommand(); if (currentCommand == null || currentCommand.Equals(lastCommand)) { break; } } //do //{ // currentCommand = UndoNextAndReturnCommand(); //} //while (currentCommand != null && !currentCommand.Equals(lastCommand)); //while ((currentCommand = UndoNextAndReturnCommand()) != null && !currentCommand.Equals(lastCommand)) ; }