Example #1
0
        private void ReadWorker(object state)
        {
            try
            {
                var pipelineInfo = (PipelineInfo)state;

                for (var index = 0; index < pipelineInfo.BlockCount; index++)
                {
                    _transformQueue.Enqueue(ReadBlock(index, pipelineInfo));
                }

                _transformQueue.CompleteAdding();
            }
            catch (Exception ex)
            {
                ProcessError(ex);
            }
        }
Example #2
0
        public void Process()
        {
            var pipelineInfo = Initialize();

            var readThread = new Thread(ReadWorker);

            readThread.Start(pipelineInfo);

            var threads = new List <Thread>(Settings.WorkThreadCount);

            for (int i = 0; i < Settings.WorkThreadCount; i++)
            {
                var compressThread = new Thread(TransformWorker);
                threads.Add(compressThread);

                compressThread.Start();
            }

            var writeThread = new Thread(WriteWorker);

            writeThread.Start(pipelineInfo);

            readThread.Join();

            foreach (var thread in threads)
            {
                thread.Join();
            }

            _writeQueue.CompleteAdding();

            writeThread.Join();

            if (_error != null)
            {
                throw new PipelineException("Exception during processing", _error);
            }
        }