예제 #1
0
        public void Execute(CancellationToken cancellationToken)
        {
            var pipeline = _pipelineFactory.GetPipeline <EventProcessingPipeline>();

            while (!cancellationToken.IsCancellationRequested)
            {
                var projection = _eventProcessor.GetProjection();
                var waiting    = true;

                if (projection != null)
                {
                    pipeline.State.Clear();
                    pipeline.State.SetProjection(projection);
                    pipeline.State.SetCancellationToken(cancellationToken);

                    pipeline.Execute();

                    if (pipeline.State.GetWorking())
                    {
                        _threadActivity.Working();
                        waiting = false;
                    }

                    _eventProcessor.ReleaseProjection(projection);
                }

                if (!waiting)
                {
                    _threadActivity.Waiting(cancellationToken);
                }
            }

            _pipelineFactory.ReleasePipeline(pipeline);
        }
        public void Execute(IThreadState state)
        {
            var pipeline = _pipelineFactory.GetPipeline <EventProcessingPipeline>();

            while (state.Active)
            {
                var projection = _eventProcessor.GetProjection();
                var waiting    = true;

                if (projection != null)
                {
                    pipeline.State.Clear();
                    pipeline.State.SetProjection(projection);
                    pipeline.State.SetThreadState(state);

                    pipeline.Execute();

                    if (pipeline.State.GetWorking())
                    {
                        _threadActivity.Working();
                        waiting = false;
                    }

                    _eventProcessor.ReleaseProjection(projection.Name);
                }

                if (!waiting)
                {
                    _threadActivity.Waiting(state);
                }
            }

            _pipelineFactory.ReleasePipeline(pipeline);
        }