Microsoft.AspNet.Server.Kestrel.Http.MessageBody.ReadAsync C# (CSharp) Méthode

ReadAsync() public méthode

public ReadAsync ( ArraySegment buffer, CancellationToken cancellationToken = default(CancellationToken) ) : Task
buffer ArraySegment
cancellationToken System.Threading.CancellationToken
Résultat Task
        public Task<int> ReadAsync(ArraySegment<byte> buffer, CancellationToken cancellationToken = default(CancellationToken))
        {
            Task<int> result = null;
            var send100Continue = 0;
            result = ReadAsyncImplementation(buffer, cancellationToken);
            if (!result.IsCompleted)
            {
                send100Continue = Interlocked.Exchange(ref _send100Continue, 0);
            }
            if (send100Continue == 1)
            {
                _context.FrameControl.ProduceContinue();
            }
            return result;
        }

Usage Example

        private Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken, object state)
        {
            ValidateState();

            var tcs  = new TaskCompletionSource <int>(state);
            var task = _body.ReadAsync(new ArraySegment <byte>(buffer, offset, count), cancellationToken);

            task.AsTask().ContinueWith((task2, state2) =>
            {
                var tcs2 = (TaskCompletionSource <int>)state2;
                if (task2.IsCanceled)
                {
                    tcs2.SetCanceled();
                }
                else if (task2.IsFaulted)
                {
                    tcs2.SetException(task2.Exception);
                }
                else
                {
                    tcs2.SetResult(task2.Result);
                }
            }, tcs, cancellationToken);
            return(tcs.Task);
        }
All Usage Examples Of Microsoft.AspNet.Server.Kestrel.Http.MessageBody::ReadAsync