ReadAsync() public méthode

public ReadAsync ( ArraySegment buffer, CancellationToken cancellationToken = default(CancellationToken) ) : Task
buffer ArraySegment
cancellationToken System.Threading.CancellationToken
Résultat Task
        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);
        }
 public override Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
 {
     return(_body.ReadAsync(new ArraySegment <byte>(buffer, offset, count), cancellationToken));
 }