コード例 #1
0
        public void StartLoop(CancellationToken token)
        {
            RxLoopConfiguration.Trace($"[{LoopGuid}] Starting loop.");
            var loopState = new LoopState(token);

            ScheduleNextRunImmediately(loopState);
        }
コード例 #2
0
        private void DoLoop(LoopState loopState)
        {
            RxLoopConfiguration.Trace($"[{LoopGuid}] DoLoop called");
            if (loopState.CancellationToken.IsCancellationRequested)
            {
                RxLoopConfiguration.Trace($"[{LoopGuid}] Loop cancelled via CancellationToken.");
                return;
            }

            RunActionInternal(loopState.CancellationToken);
            ScheduleNextRun(loopState);
        }
コード例 #3
0
 private void ScheduleNextRun(LoopState loopState)
 {
     RxLoopConfiguration.Trace($"[{LoopGuid}] Scheduling next run.");
     _schedulerProvider.ThreadPool.Schedule(
         loopState,
         DelayBetweenRuns,
         (scheduler, state) =>
     {
         DoLoop(state);
         return(Disposable.Empty);
     }
         );
 }
コード例 #4
0
 private void RunActionInternal(CancellationToken token)
 {
     try
     {
         RxLoopConfiguration.Trace(DebugOutput());
         _action(token);
     }
     catch (Exception e)
     {
         RxLoopConfiguration.Trace($"[{LoopGuid}] Error running action");
         RxLoopConfiguration.ExceptionHandler?.HandleException(e);
     }
 }
コード例 #5
0
 private void ScheduleNextRunImmediately(LoopState loopState)
 {
     RxLoopConfiguration.Trace($"[{LoopGuid}] Scheduling immediate next run.");
     _schedulerProvider.ThreadPool.Schedule(
         loopState,
         TimeSpan.Zero,
         (scheduler, state) =>
     {
         DoLoop(state);
         return(Disposable.Empty);
     }
         );
 }