muf icon indicating copy to clipboard operation
muf copied to clipboard

UndoBatch doesn't allow for cancellation of batch

Open nathanaw opened this issue 6 years ago • 1 comments

The documentation says that UndoBatch is designed similarly to TransactionScope, but TransactionScope requires a "ts.Complete()" call to commit, otherwise the change is rolled back. In the current UndoBatch, there's no ability to rollback. Conforming to the TransactionScope pattern, or at least providing some kind of .Rollback() would be very useful.


I worked around it with

bool success = true;
using (new UndoBatch(...)) {
    ...
}

if (!success) {
    var root = UndoService.Current[undoroot];
    root.Undo();
}

nathanaw avatar Aug 31 '17 23:08 nathanaw