Esempio n. 1
0
        protected ActorTimer RegisterTimer(Func <Task> callback, TimeSpan interval, int?runCount = null, Boolean autoStart = true, Boolean sync = true)
        {
            Func <Task> innerCallback;

            if (sync)
            {
                innerCallback = () => { return(QueueExecuteInline(callback)); };
            }
            else
            {
                innerCallback = () => { return(ExecuteInline(callback)); };
            }

            var timer = new ActorTimer(innerCallback, interval, runCount, _timersCts.Token);

            _timers.Add(timer);

            timer.OnFinish(async() => { _timers.Remove(timer); });

            timer.OnError(async(ex) => { _telemetry.Exception(ex); });

            if (autoStart)
            {
                timer.Start();
            }

            return(timer);
        }
Esempio n. 2
0
        protected ActorTimer RegisterTimer(Func <Task> callback, TimeSpan interval, int?runCount = null, Boolean autoStart = true)
        {
            var timer = new ActorTimer(callback, interval, runCount, _timersCts.Token);

            _timers.Add(timer);

            if (autoStart)
            {
                timer.Start();
            }

            return(timer);
        }