Beispiel #1
0
		private static void CheckThread(ModuleThread aThread)
		{
			if (aThread.WatchdogEnabled && aThread.MustRun)
			{
				theLogger.DebugFormat("Watchdog test on thread '{0}'", aThread.Name);
				if (DateTime.Now - aThread.LastWatchdogReset > aThread.WatchdogDelay)
				{
					theLogger.Error("Watchdog timeout !!! Killing and restarting thread " + aThread.Name + "...");
					aThread.Restart();
				}
				else
				{
					foreach (ModuleThread subThread in aThread.Threads)
					{
						CheckThread(subThread);
					}
				}
			}
		}
Beispiel #2
0
		private void OnThreadRemoved(ModuleThread aThread)
		{
			theLogger.DebugFormat("Thread Removed");
			if (ThreadRemoved != null)
				ThreadRemoved(this, new ModuleThreadEventArgs { Thread = aThread });
		}
Beispiel #3
0
		/// <summary>
		/// Remove a sub thread
		/// </summary>
		/// <param name="moduleThread">The thread</param>
		protected void RemoveThread(ModuleThread moduleThread)
		{
			theLogger.DebugFormat("Removing Thread '{0}'", moduleThread.Name);

			if(moduleThread.State != RunState.Stopped)
			{
				moduleThread.Stop();
			}

			lock (theThreads)
			{
				theThreads.Remove(moduleThread);
			}

			OnThreadRemoved(moduleThread);

			moduleThread.Dispose();
		}
Beispiel #4
0
		/// <summary>
		/// Add a sub thread
		/// </summary>
		/// <param name="moduleThread">The thread</param>
		protected void AddThread(ModuleThread moduleThread)
		{
			if (theThreads.Contains(moduleThread))
				return;

			theLogger.DebugFormat("Adding Thread '{0}'",moduleThread.Name);

			moduleThread.ParentThread = this;
			OnThreadAdded(moduleThread);

			moduleThread.Initialize();

			lock (theThreads)
			{
				theThreads.Add(moduleThread);
			}

			// If we are already running and the thread is marked as autostart, let's start it
			if(moduleThread.AutoStart)
			{
				theLogger.DebugFormat("Starting newly added Thread '{0}'",moduleThread.Name);
				moduleThread.Start();
			}
		}