public void Dispose() { if (IsDisposed) { return; } IsDisposed = true; var disposeExceptions = new List <Exception>(); foreach (var transactionFeature in _transactionFeatures.Values) { try { transactionFeature.Dispose(); } catch (Exception ex) { disposeExceptions.Add(ex); } } if (disposeExceptions.Count > 0) { throw new AggregateException(disposeExceptions); } DisposeHandler.Invoke(this, this); }
public void OnDispose(DisposeHandler handler) { var myAction = new MyAction(handler); if (Interlocked.CompareExchange(ref disposeAction, myAction, null) != null) { throw new InvalidOperationException(); } }
public void Dispose() { if (IsDisposed) { throw new InvalidOperationException("this unit of work is already dispose"); } IsDisposed = true; DisposeHandler?.Invoke(this, this); _parentUow = null; }
public MyAction(DisposeHandler dispose) { Dispose = dispose; }