/// <summary> /// To call from the action callback. /// </summary> public void NotifyCallbackCalled() { int LastTimerDispatcherCount = Interlocked.Decrement(ref TimerDispatcherCount); UpdateWatch.Restart(); AddLog($"Watch restarted, Elapsed = {LastTotalElapsed}, pending count = {LastTimerDispatcherCount}"); }
private void OnUpdate() { UpdateWatch.Restart(); try { ServiceStartMode?PreviousStartType = StartType; bool LockIt = GetSettingBool("Locked", true); ServiceController[] Services = ServiceController.GetServices(); foreach (ServiceController Service in Services) { if (Service.ServiceName == WindowsUpdateServiceName) { StartType = Service.StartType; if (PreviousStartType.HasValue && PreviousStartType.Value != StartType.Value) { App.AddLog("Start type changed"); ChangeLockMode(Service, LockIt); } StopIfRunning(Service, LockIt); PreviousStartType = StartType; break; } } ZombifyMe.Zombification.SetAlive(); } catch (Exception e) { App.AddLog($"(from OnUpdate) {e.Message}"); } }
private void OnUpdate() { try { Logger.AddLog("%% Running timer callback"); int LastTimerDispatcherCount = Interlocked.Decrement(ref TimerDispatcherCount); UpdateWatch.Restart(); Logger.AddLog($"Watch restarted, Elapsed = {LastTotalElapsed}, pending count = {LastTimerDispatcherCount}"); Settings.RenewKey(); Logger.AddLog("Key renewed"); ServiceStartMode?PreviousStartType = StartType; bool LockIt = IsSettingLock; Logger.AddLog("Lock setting read"); ServiceController[] Services = ServiceController.GetServices(); if (Services == null) { Logger.AddLog("Failed to get services"); } else { Logger.AddLog($"Found {Services.Length} service(s)"); foreach (ServiceController Service in Services) { if (Service.ServiceName == WindowsUpdateServiceName) { Logger.AddLog($"Checking {Service.ServiceName}"); StartType = Service.StartType; Logger.AddLog($"Current start type: {StartType}"); if (PreviousStartType.HasValue && PreviousStartType.Value != StartType.Value) { Logger.AddLog("Start type changed"); ChangeLockMode(Service, LockIt); } StopIfRunning(Service, LockIt); PreviousStartType = StartType; break; } } } ZombifyMe.Zombification.SetAlive(); Logger.AddLog("%% Timer callback completed"); } catch (Exception e) { Logger.AddLog($"(from OnUpdate) {e.Message}"); } }