示例#1
0
 async static Task <int> asynchLoadBuffer(int offset, int count)
 {
     //if the temporary input stream is null, throw a NullReferenceException
     if (tempInputStream == null)
     {
         throw new NullReferenceException();
     }
     //if arguments are out of range, throw an ArgumentOutOfRangeException
     if (offset < 0 || offset + count > tempInputStream.Length || count <= 0)
     {
         throw new ArgumentOutOfRangeException();
     }
     //if the temporary input buffer is null, create an instance
     if (tempInputBuffer == null)
     {
         tempInputBuffer = new byte[tempInputStream.Length];
     }
     return(await tempInputStream.ReadAsync(tempInputBuffer, offset, count));
 }