public void Unlock() { Debug.Assert(Locked); lock (this) { OwningTransaction = null; LinkedListNode <KeyValuePair <Transaction, ManualResetEvent> > node = null; if (PendingTransactions.Count > 0) { node = PendingTransactions.First; PendingTransactions.RemoveFirst(); } if (node != null) { Transaction transaction = node.Value.Key; ManualResetEvent manualEvent = node.Value.Value; Lock(transaction); lock (manualEvent) { if (!manualEvent.SafeWaitHandle.IsClosed) { manualEvent.Set(); } } } } }