Ejemplo n.º 1
0
        public override async Task <int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
        {
            // Still have leftover data?
            if (_currentData.Length > 0)
            {
                return(ReadInternalBuffer(buffer, offset, count));
            }

            cancellationToken.Register(() =>
            {
                _syncPoint.CancelWaitForSyncPoint(cancellationToken);
            });

            // Wait until data is provided by AddDataAndWait
            await _syncPoint.WaitForSyncPoint();

            return(ReadInternalBuffer(buffer, offset, count));
        }