예제 #1
0
 internal ReaderWriterGateReleaser(ReaderWriterGateCallback callback, ReaderWriterGate gate,
                                   Boolean reader, Object state, AsyncResult <Object> ar)
 {
     m_callback    = callback;
     m_gate        = gate;
     m_flags       = reader ? ReleaserFlags.Reader : ReleaserFlags.Writer;
     m_state       = state;
     m_asyncResult = ar;
 }
예제 #2
0
        private Boolean Complete(Exception exception, Object resultValue, Boolean completeOnReturn)
        {
            Boolean success = false; // Assume this call fails

            if (m_gate != null)
            {
                // Gate not already released; release it
                Boolean reader = (m_flags & ReleaserFlags.Writer) == 0;
                m_gate.Release(reader); // Release the gate
                m_gate  = null;         // Mark as complete so we don't complete again
                success = true;
            }

            // If completeOnReturn is true, then the gate is being released explicitly (via Release) and we should NOT complete the operation

            // If we're returning and we're released the gate, then indicate that the operation is complete
            if (completeOnReturn)
            {
                success = true;
            }
            else
            {
                // Else we should complete this operation if we didn't do it already
                if ((m_flags & ReleaserFlags.Completed) == 0)
                {
                    m_flags |= ReleaserFlags.Completed;
                    // Signal the completion with the exception or the ResultValue
                    if (exception != null)
                    {
                        m_asyncResult.SetAsCompleted(exception, false);
                    }
                    else
                    {
                        m_asyncResult.SetAsCompleted(resultValue, false);
                    }
                    success = true;
                }
            }
            return(success); // This call to complete succeeded
        }
예제 #3
0
      private Boolean Complete(Exception exception, Object resultValue, Boolean completeOnReturn) {
         Boolean success = false;  // Assume this call fails

         if (m_gate != null) {
            // Gate not already released; release it
            Boolean reader = (m_flags & ReleaserFlags.Writer) == 0;
            m_gate.Release(reader);  // Release the gate
            m_gate = null; // Mark as complete so we don't complete again
            success = true;
         }

         // If completeOnReturn is true, then the gate is being released explicitly (via Release) and we should NOT complete the operation

         // If we're returning and we're released the gate, then indicate that the operation is complete
         if (completeOnReturn) { success = true; } else {
            // Else we should complete this operation if we didn't do it already
            if ((m_flags & ReleaserFlags.Completed) == 0) {
               m_flags |= ReleaserFlags.Completed;
               // Signal the completion with the exception or the ResultValue
               if (exception != null) m_asyncResult.SetAsCompleted(exception, false);
               else m_asyncResult.SetAsCompleted(resultValue, false);
               success = true;
            }
         }
         return success;   // This call to complete succeeded
      }
예제 #4
0
      internal ReaderWriterGateReleaser(ReaderWriterGateCallback callback, ReaderWriterGate gate,
         Boolean reader, Object state, AsyncResult<Object> ar) {

         m_callback = callback;
         m_gate = gate;
         m_flags = reader ? ReleaserFlags.Reader : ReleaserFlags.Writer;
         m_state = state;
         m_asyncResult = ar;
      }