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); }
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); }
public bool Produce(Consumer.Singular consumer, Worker worker) { lastPostResult = consumer.Dispatch(this, worker); Dev.Assert(lastPostResult); return(lastPostResult); }