Exemplo n.º 1
0
 public RelayQueueProcessor(IRelayAgent <TInput, TOutput> agent,
                            IBufferManager <TInput> bufferManager, IProgressive progressReporter,
                            IDataSubscribable <TInput> input)
     : base(agent, progressReporter, bufferManager, input)
 {
     _agent = agent;
 }
        public SeriesProcessor(IWorkManager <TWorkItem> workManager,
                               IProgressive progressReporter,
                               IBufferManager <TWorkItem> bufferManager, IDataSubscribable <TWorkItem> input)
            : base(progressReporter, bufferManager, workManager)
        {
            WorkManager = workManager;

            BufferManager = bufferManager;
            DataInput     = input;
            DataInput?.AddSubscriber(this);
        }
 internal ManageableProgressive(IProgressManager manager, IProgressive progressive)
 {
     Manager         = manager ?? throw new ArgumentNullException(nameof(manager));
     _progressive    = progressive ?? throw new ArgumentNullException(nameof(progressive));
     Id              = Manager.CreateId();
     _taskCompletion = new TaskCompletionSource <int>();
     if (_progressive is Progressive p)
     {
         StateDFA = p.StateDFA;
         StateDFA.StateChanged += Progressive_ProgressStateChanged;
     }
     else
     {
         StateDFA = new DFA <ProgressState>(ProgressState.Initial, def =>
         {
             def(ProgressState.Initial, new[] { ProgressState.Ready, ProgressState.Progressing, ProgressState.Error });
             def(ProgressState.Ready, new[] { ProgressState.Progressing, ProgressState.Suspend, ProgressState.Error });
             def(ProgressState.Progressing, new[] { ProgressState.Suspend, ProgressState.Completed, ProgressState.Error });
             def(ProgressState.Suspend, new[] { ProgressState.Ready, ProgressState.Progressing, ProgressState.Error });
         });
         _progressive.ProgressStateChanged += Progressive_ProgressStateChanged;
     }
 }
Exemplo n.º 4
0
        public ManageableProgressive Add(IProgressive progressive)
        {
            var mp = new ManageableProgressive(this, progressive);

            mp.ProgressCompleted    += Item_ProgressCompleted;
            mp.ProgressValueChanged += Item_ProgressValueChanged;
            lock (this)
            {
                var @new = new ManageableProgressive[Count + 1];
                var i    = 0;
                foreach (var item in _items)
                {
                    if (item != null)
                    {
                        @new[i] = item;
                        i++;
                    }
                }
                @new[i] = mp;
                Count   = Count + 1;
                _items  = @new;
            }
            return(mp);
        }