/// <summary>
        /// Reads asynchronously data from a byte stream
        /// </summary>
        /// <typeparam name="T">A value type.</typeparam>
        /// <param name="byteStream">A valid IMFByteStream instance.</param>
        /// <param name="buffer">An array of T that receives the data.</param>
        /// <param name="offset">An index offset in buffer at which to begin storing the data read from the byte stream.</param>
        /// <param name="count">The maximum number of items to be read from the byte stream.</param>
        /// <returns>A task that represents the asynchronous read operation. The task's result contain the number of items read.</returns>
        public static Task <int> ReadAsync <T>(this IMFByteStream byteStream, T[] buffer, int offset, int count) where T : struct
        {
            if (buffer == null)
            {
                throw new ArgumentNullException("value");
            }

            if (offset > buffer.Length)
            {
                throw new ArgumentNullException("offset");
            }

            if ((offset + count) > buffer.Length)
            {
                throw new ArgumentOutOfRangeException("count");
            }

            ArraySegment <T> arraySegment = new ArraySegment <T>(buffer, offset, count);

            return(IMFByteStreamExtensions.ReadAsync <T>(byteStream, arraySegment));
        }
 /// <summary>
 /// Reads asynchronously data from a byte stream
 /// </summary>
 /// <param name="byteStream">A valid IMFByteStream instance.</param>
 /// <param name="buffer">A byte array that receives the data.</param>
 /// <param name="offset">An offset from the start of the buffer at which to begin storing the data read from the byte stream.</param>
 /// <param name="count">The maximum number of bytes to be read from the byte stream.</param>
 /// <returns>A task that represents the asynchronous read operation. The task's result contain the number of bytes read.</returns>
 public static Task <int> ReadAsync(this IMFByteStream byteStream, byte[] buffer, int offset, int count)
 {
     return(IMFByteStreamExtensions.ReadAsync <byte>(byteStream, buffer, offset, count));
 }