Esempio n. 1
0
        public async override Task Stop()
        {
            await base.Stop();

            if (listRefreshTimer != null)
            {
                listRefreshTimer.Dispose();
                if (this.runTask is Task task)
                {
                    await task;
                }
            }

            foreach (LocalReminderData r in localReminders.Values)
            {
                r.StopReminder();
            }

            // for a graceful shutdown, also handover reminder responsibilities to new owner, and update the ReminderTable
            // currently, this is taken care of by periodically reading the reminder table
        }
Esempio n. 2
0
        public void Participate(ISiloLifecycle lifecycle)
        {
            lifecycle.Subscribe(
                nameof(ClientObserverRegistrar),
                ServiceLifecycleStage.RuntimeServices,
                _ => Task.CompletedTask,
                async ct =>
            {
                shutdownCancellation.Cancel();
                refreshTimer?.Dispose();

                if (clientRefreshLoopTask is Task task)
                {
                    await Task.WhenAny(ct.WhenCancelled(), task);
                }
            });
        }
Esempio n. 3
0
 void ILifecycleParticipant <ISiloLifecycle> .Participate(ISiloLifecycle lifecycle)
 {
     lifecycle.Subscribe(
         nameof(IncomingRequestMonitor),
         ServiceLifecycleStage.BecomeActive,
         ct =>
     {
         _runTask = Task.Run(this.Run);
         return(Task.CompletedTask);
     },
         async ct =>
     {
         _scanPeriodTimer.Dispose();
         if (_runTask is Task task)
         {
             await Task.WhenAny(task, ct.WhenCancelled());
         }
     });
 }