System.Net.AsyncProtocolRequest.CompleteUserWithError C# (CSharp) Method

CompleteUserWithError() private method

private CompleteUserWithError ( Exception e ) : void
e Exception
return void
        internal void CompleteUserWithError(Exception e) => UserAsyncResult.InvokeCallback(e);

Usage Example

        private static void ReadCallback(IAsyncResult transportResult)
        {
            if (!(transportResult.AsyncState is FixedSizeReader))
            {
                NetEventSource.Fail(null, "State type is wrong, expected FixedSizeReader.");
            }

            if (transportResult.CompletedSynchronously)
            {
                return;
            }

            FixedSizeReader      reader  = (FixedSizeReader)transportResult.AsyncState;
            AsyncProtocolRequest request = reader._request;

            // Async completion.
            try
            {
                int bytes = reader._transport.EndRead(transportResult);

                if (reader.CheckCompletionBeforeNextRead(bytes))
                {
                    return;
                }

                reader.StartReading();
            }
            catch (Exception e)
            {
                if (request.IsUserCompleted)
                {
                    throw;
                }

                request.CompleteUserWithError(e);
            }
        }