private async Task StageBlockAsync( StreamPartition block, string blockId, BlobRequestConditions conditions, IProgress <long> progressHandler, CancellationToken cancellationToken) { try { await _client.StageBlockAsync( blockId, new MemoryStream(block.Bytes, 0, block.Length, writable : false), conditions : conditions, progressHandler : progressHandler, cancellationToken : cancellationToken) .ConfigureAwait(false); } finally { // Return the memory used by the block to our ArrayPool as soon // as we've staged it block.Dispose(); } }