Exemplo n.º 1
0
        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);
            }));
        }
Exemplo n.º 2
0
        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);
                }
            }));
        }