Exemple #1
0
 internal void Complete(int read, uint errorCode = UnsafeNclNativeMethods.ErrorCodes.ERROR_SUCCESS)
 {
     if (_requestStream.TryCheckSizeLimit(read + (int)DataAlreadyRead, out var exception))
     {
         _tcs.TrySetException(exception);
     }
     else if (_tcs.TrySetResult(read + (int)DataAlreadyRead))
     {
         RequestStream.UpdateAfterRead((uint)errorCode, (uint)(read + DataAlreadyRead));
         if (_callback != null)
         {
             try
             {
                 _callback(this);
             }
             catch (Exception)
             {
                 // TODO: Exception handling? This may be an IO callback thread and throwing here could crash the app.
             }
         }
     }
     Dispose();
 }