public IAsyncResult BeginWrite(ReaderWriterGateCallback callback, Object state, AsyncCallback asyncCallback, Object asyncState) { AsyncResult <Object> ar = new AsyncResult <Object>(asyncCallback, asyncState); ReaderWriterGateReleaser releaser = new ReaderWriterGateReleaser(callback, this, false, state, ar); m_syncLock.Enter(true); switch (m_state) { case ReaderWriterGateStates.Free: // If Free "RFW -> OBW, invoke, return case ReaderWriterGateStates.ReservedForWriter: m_state = ReaderWriterGateStates.OwnedByWriter; ThreadPool.QueueUserWorkItem(releaser.Invoke); break; case ReaderWriterGateStates.OwnedByReaders: // If OBR | OBRAWP -> OBRAWP, queue, return case ReaderWriterGateStates.OwnedByReadersAndWriterPending: m_state = ReaderWriterGateStates.OwnedByReadersAndWriterPending; m_qWriteRequests.Enqueue(releaser); break; case ReaderWriterGateStates.OwnedByWriter: // If OBW, queue, return m_qWriteRequests.Enqueue(releaser); break; } m_syncLock.Leave(); return(ar); }
private void AddToValues(Int64 lowAddend, Int64 highAddend, Int64 currentAddend) { Boolean reportProgressUpdate; m_lock.Enter(true); reportProgressUpdate = SetValues(true, m_low + lowAddend, m_high + highAddend, m_current + currentAddend); m_lock.Leave(); ReportProgressUpdate(reportProgressUpdate); }
/// <summary>Implements the ResourceLock's Leave behavior.</summary> protected override void OnLeave(Boolean exclusive) { m_resLock.Leave(); }