public void Batch(Action <IStorageActionsAccessor> action) { if (disposed) { Trace.WriteLine("TransactionalStorage.Batch was called after it was disposed, call was ignored."); return; // this may happen if someone is calling us from the finalizer thread, so we can't even throw on that } if (current.Value != null) { action(current.Value); return; } disposerLock.EnterReadLock(); try { Interlocked.Exchange(ref lastUsageTime, DateTime.Now.ToBinary()); StorageActionsAccessor storageActionsAccessor; using (queuesStroage.BeginTransaction()) { storageActionsAccessor = new StorageActionsAccessor(queuesStroage, uuidGenerator); current.Value = storageActionsAccessor; action(current.Value); queuesStroage.Commit(); } storageActionsAccessor.InvokeOnCommit(); } finally { disposerLock.ExitReadLock(); current.Value = null; } }
public void Batch(Action<IStorageActionsAccessor> action) { if (disposed) { Trace.WriteLine("TransactionalStorage.Batch was called after it was disposed, call was ignored."); return; // this may happen if someone is calling us from the finalizer thread, so we can't even throw on that } if (current.Value != null) { action(current.Value); return; } disposerLock.EnterReadLock(); try { Interlocked.Exchange(ref lastUsageTime, DateTime.Now.ToBinary()); StorageActionsAccessor storageActionsAccessor; using (queuesStroage.BeginTransaction()) { storageActionsAccessor = new StorageActionsAccessor(queuesStroage, uuidGenerator); current.Value = storageActionsAccessor; action(current.Value); queuesStroage.Commit(); } storageActionsAccessor.InvokeOnCommit(); } finally { disposerLock.ExitReadLock(); current.Value = null; } }