public virtual Task WriteBlock(BlockData block) { return(_taskFactory.StartNew(() => { var header = block.GenerateHeader().ToArray(); WriteAsync(header).AsTask().Wait(); WriteAsync(block.Data).AsTask().Wait(); FlushAsync().Wait(); Logger.LogDebug("Write {0}", block); })); }
private Task WriteInternal(BlockData block) { return(_taskFactory.StartNew(() => { try { var header = block.GenerateHeader().ToArray(); WriteAsync(header).AsTask().Wait(); if (block.Data.Length != 0) { WriteAsync(block.Data).AsTask().Wait(); } FlushAsync().Wait(); } finally { Logger.LogDebug("Sending {0}", block); } })); }