예제 #1
0
 protected static void OnWrite(IAsyncResult result)
 {
     if (!result.CompletedSynchronously)
     {
         MultiAsyncResult multiResult = (MultiAsyncResult)result.AsyncState;
         BaseWriter       thisPtr     = (BaseWriter)multiResult.Context;
         try
         {
             thisPtr._stream.EndWrite(result);
             multiResult.Leave();
         }
         catch (Exception e)
         {
             multiResult.Leave(e);
         }
     }
 }
예제 #2
0
 protected void Flush(MultiAsyncResult multiResult)
 {
     if (_bufferBuilder.Length > 0)
     {
         if (multiResult != null)
         {
             multiResult.Enter();
             IAsyncResult result = _stream.BeginWrite(_bufferBuilder.GetBuffer(), 0,
                                                      _bufferBuilder.Length, s_onWrite, multiResult);
             if (result.CompletedSynchronously)
             {
                 _stream.EndWrite(result);
                 multiResult.Leave();
             }
         }
         else
         {
             _stream.Write(_bufferBuilder.GetBuffer(), 0, _bufferBuilder.Length);
         }
         _bufferBuilder.Reset();
     }
 }