/// <summary> /// Starts a new interval action. /// </summary> /// <param name="func">The function.</param> /// <param name="timeSpan">The time span.</param> /// <returns></returns> public static IntervalAction Start(Func <Task> func, TimeSpan timeSpan) { var instance = new IntervalAction(func, timeSpan); instance.Start(); return(instance); }
/// <summary> /// Start Stage 2. /// Called after Hot load caches and start-up activities( EF migrations etc ) /// </summary> public static void StartStage2() { if (!_isWebFarmEnabledAndUnlocked) { return; } if (_startStage != 1) { LogException($"Web Farm cannot start stage 2 when at stage {_startStage}"); return; } Debug("Start Stage 2"); using (var rockContext = new RockContext()) { // Mark IsActive true // Update LastSeenDateTime = now var webFarmNode = GetNode(rockContext, NodeName); webFarmNode.IsActive = true; webFarmNode.LastSeenDateTime = RockDateTime.Now; rockContext.SaveChanges(); } // Start the polling cycle _pollingInterval = IntervalAction.Start(DoIntervalProcessingAsync, TimeSpan.FromSeconds(decimal.ToDouble(_pollingIntervalSeconds))); // Announce startup to EventBus PublishEvent(EventType.Startup); _startStage = 2; Debug("Done with Stage 2"); }