/// <summary> /// Thread that is waiting for signals to perform checks. /// </summary> private void ExecutiveThread() { log.Info("()"); executiveThreadFinished.Reset(); List <WaitHandle> handleList = new List <WaitHandle>(); handleList.Add(ShutdownSignaling.ShutdownEvent); foreach (CronJob job in jobs.Values) { handleList.Add(job.Event); } WaitHandle[] handles = handleList.ToArray(); Data.Database database = (Data.Database)Base.ComponentDictionary["Data.Database"]; Network.LocationBasedNetwork locationBasedNetwork = (Network.LocationBasedNetwork)Base.ComponentDictionary["Network.LocationBasedNetwork"]; ImageManager imageManager = (ImageManager)Base.ComponentDictionary["Data.ImageManager"]; Network.Server server = (Network.Server)Base.ComponentDictionary["Network.Server"]; Network.NeighborhoodActionProcessor neighborhoodActionProcessor = (Network.NeighborhoodActionProcessor)Base.ComponentDictionary["Network.NeighborhoodActionProcessor"]; Network.CAN.ContentAddressNetwork contentAddressNetwork = (Network.CAN.ContentAddressNetwork)Base.ComponentDictionary["Network.ContentAddressNetwork"]; while (!ShutdownSignaling.IsShutdown) { log.Info("Waiting for event."); int index = WaitHandle.WaitAny(handles); if (handles[index] == ShutdownSignaling.ShutdownEvent) { log.Info("Shutdown detected."); break; } CronJob job = null; foreach (CronJob cronJob in jobs.Values) { if (handles[index] == cronJob.Event) { job = cronJob; break; } } log.Trace("Job '{0}' activated.", job.Name); switch (job.Name) { case "checkFollowersRefresh": database.CheckFollowersRefresh(); break; case "checkExpiredHostedIdentities": database.CheckExpiredHostedIdentities(); break; case "checkExpiredNeighbors": if (locationBasedNetwork.LocServerInitialized) { database.CheckExpiredNeighbors(); } else { log.Debug("LOC component is not in sync with the LOC server yet, checking expired neighbors will not be executed now."); } break; case "deleteUnusedImages": imageManager.ProcessImageDeleteList(); break; case "refreshLocData": locationBasedNetwork.RefreshLoc(); break; case "checkInactiveClientConnections": server.CheckInactiveClientConnections(); break; case "checkNeighborhoodActionList": neighborhoodActionProcessor.CheckActionList(); break; case "ipnsRecordRefresh": contentAddressNetwork.IpnsRecordRefresh().Wait(); break; } } executiveThreadFinished.Set(); log.Info("(-)"); }