示例#1
0
        private void NotifyOfPendingWork()
        {
            if (_processingStarted)
            {
                return;
            }

            var orleansTs = TaskScheduler.Current;

            if (ProcessOnThreadPool)
            {
                Task.Run(async() =>
                {
                    while (!_proccessingStopped)
                    {
                        TInput itemToProcess;
                        if (!_input.TryDequeue(out itemToProcess))
                        {
                            await Task.Delay(7);
                            continue;
                        }

                        var processed = _processor.Process(itemToProcess);
                        await Task.Factory.StartNew(
                            async() => await _target.SendAsync(processed), CancellationToken.None, TaskCreationOptions.None, orleansTs);
                    }
                });
            }
            else
            {
                throw new NotImplementedException();
            }

            _processingStarted = true;
        }