public IDisposable RegisterTimer(Grain grain, Func <object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period) { var timer = GrainTimer.FromTaskCallback(this.scheduler, this.timerLogger, asyncCallback, state, dueTime, period, activationData: grain?.Data); grain?.Data.OnTimerCreated(timer); timer.Start(); return(timer); }
public IDisposable RegisterTimer(IGrainContext grainContext, Func <object, Task> asyncCallback, object state, TimeSpan dueTime, TimeSpan period) { var timer = GrainTimer.FromTaskCallback(this.timerLogger, asyncCallback, state, dueTime, period, grainContext: grainContext); grainContext?.GetComponent <IGrainTimerRegistry>().OnTimerCreated(timer); timer.Start(); return(timer); }
public void StopReminder(TraceLogger logger) { if (Timer != null) { Timer.Dispose(); } Timer = null; }
public void StartTimer(OrleansTaskScheduler scheduler, Func <object, Task> asyncCallback, Logger Logger) { StopReminder(Logger); // just to make sure. var dueTimeSpan = CalculateDueTime(); Timer = GrainTimer.FromTaskCallback(scheduler, asyncCallback, this, dueTimeSpan, period, name: ReminderName); if (Logger.IsVerbose) { Logger.Verbose("Reminder {0}, Due time{1}", this, dueTimeSpan); } Timer.Start(); }
public void StartTimer(Func <object, Task> asyncCallback, TraceLogger logger) { StopReminder(logger); // just to make sure. var dueTimeSpan = CalculateDueTime(); Timer = GrainTimer.FromTaskCallback(asyncCallback, this, dueTimeSpan, period, name: ReminderName); if (logger.IsVerbose) { logger.Verbose("Reminder {0}, Due time{1}", this, dueTimeSpan); } Timer.Start(); }
private void StartTimer() { if (timer != null) timer.Dispose(); timer = GrainTimer.FromTimerCallback( this.RuntimeClient.Scheduler, this.OnGossipTimerTick, null, this.backgroundGossipInterval, this.backgroundGossipInterval, "MultiCluster.GossipTimer"); timer.Start(); }
protected override async Task StartInBackground() { await DoInitialReadAndUpdateReminders(); if (Status == GrainServiceStatus.Booting) { var random = new SafeRandom(); listRefreshTimer = GrainTimer.FromTaskCallback( _ => DoInitialReadAndUpdateReminders(), null, random.NextTimeSpan(InitialReadRetryPeriod), InitialReadRetryPeriod, name: "ReminderService.ReminderListInitialRead"); listRefreshTimer.Start(); } }
public Task Stop() { logger.Info(ErrorCode.RS_ServiceStopping, "Stopping reminder system target"); status = ReminderServiceStatus.Stopped; ring.UnSubscribeFromRangeChangeEvents(this); if (listRefresher != null) { listRefresher.Dispose(); listRefresher = null; } foreach (LocalReminderData r in localReminders.Values) { r.StopReminder(logger); } // 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 return(TaskDone.Done); }
public Task Start() { requestProcessor = GrainTimer.FromTaskCallback(this.RuntimeClient.Scheduler, this.loggerFactory.CreateLogger <GrainTimer>(), ProcessRequests, null, TimeSpan.FromMilliseconds(0), TimeSpan.FromMilliseconds(10), "TransactionAgent"); requestProcessor.Start(); return(Task.CompletedTask); }