コード例 #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();
 }
コード例 #2
0
 internal RequestStreamAsyncResult(RequestStream requestStream, object userState, AsyncCallback callback, byte[] buffer, int offset, uint dataAlreadyRead)
     : this(requestStream, userState, callback, buffer, offset, dataAlreadyRead, new CancellationTokenRegistration())
 {
 }
コード例 #3
0
 internal RequestStreamAsyncResult(RequestStream requestStream, object userState, AsyncCallback callback, uint dataAlreadyRead)
     : this(requestStream, userState, callback)
 {
     _dataAlreadyRead = dataAlreadyRead;
 }
コード例 #4
0
 internal RequestStreamAsyncResult(RequestStream requestStream, object userState, AsyncCallback callback)
 {
     _requestStream = requestStream;
     _tcs           = new TaskCompletionSource <int>(userState);
     _callback      = callback;
 }