Exemple #1
0
        public void Start(Message.Consumer.Singular consumer, Heartbeat worker)
        {
            Dev.Assert(_cts == null);
            _cts = new CancellationTokenSource();

            _consumer = consumer;
            _worker   = worker;

            var startTime = Utility.LogicTime.TimeTicks;

            Task.Factory.StartNew((@object) =>
            {
                Timeout timeout = (@object as Timeout);
                while (this._cts.IsCancellationRequested == false)
                {
                    timeout.OnTimeout();
                }
            }, this
                                  , TaskCreationOptions.LongRunning
                                  | TaskCreationOptions.DenyChildAttach);
        }
Exemple #2
0
        public bool Start()
        {
            Dev.Assert(_cts == null);
            _cts = new CancellationTokenSource();

            Task.Factory.StartNew((@singular) => Singular.Process(@singular as Singular)
                                  , this
                                  , TaskCreationOptions.LongRunning
                                  | TaskCreationOptions.DenyChildAttach)
            .ContinueWith(
                (prevTasks) =>
            {
                if (prevTasks.Exception is AggregateException)
                {
                    prevTasks.Exception.Handle((ex) => _handler(ex));
                }
            }, TaskContinuationOptions.OnlyOnFaulted
                | TaskContinuationOptions.ExecuteSynchronously
                | TaskContinuationOptions.DenyChildAttach);

            return(true);
        }
Exemple #3
0
 public bool Produce(Consumer.Singular consumer, Worker worker)
 {
     lastPostResult = consumer.Dispatch(this, worker);
     Dev.Assert(lastPostResult);
     return(lastPostResult);
 }