예제 #1
0
        private void WriterWorkerStart()
        {
            try
            {
                SignOutputStream(outputStream);

                while (service.IsNotEnded)
                {
                    if (service.Token.IsCancellationRequested)
                    {
                        return;
                    }

                    var nextPart = service.GetNextPart();

                    var resultStream = nextPart.ResultStream;

                    InsertPartStreamInfo(outputStream, (int)resultStream.Length);

                    resultStream.Seek(0, SeekOrigin.Begin);
                    var buffer = new byte[resultStream.Length];
                    resultStream.CopyTo(outputStream, buffer, 0, buffer.Length);

                    resultStream.Close();
                }

                outputStream.Close();

                service.Clear();
            }
            catch (Exception e)
            {
                var errorMessage = "Exception in writer worker: " + e.Message;

                service.HandleException(e, errorMessage);
            }
        }