src/openSourceC.DotNetLibrary.Windows/ServiceProcess/ServiceApplicationBase.cs
/// <summary>
///		Executes when a Stop command is sent to the service by the Service Control Manager (SCM).
/// </summary>
Executes when a Stop command is sent to the service by the Service Control Manager (SCM).
Executes when a Stop command is sent to the service by the Service Control Manager ( SCM ) .
protected override void OnStop()
		{
			for (bool firstPass = true; _processorThreads != null && _processorThreads.Count != 0; firstPass = false)
			{
				foreach (KeyValuePair<Thread, ServiceProcessorBase> processorThread in _processorThreads.ToArray())
				{
					if (firstPass && processorThread.Key.IsAlive)
					{
						Log.Info("Thread.Join: {0}", (string.IsNullOrWhiteSpace(processorThread.Key.Name) ? processorThread.Key.ManagedThreadId.ToString() : processorThread.Key.Name));
					}
					if (!processorThread.Key.IsAlive || processorThread.Key.Join(10))
					{
						processorThread.Value.Dispose();
						_processorThreads.Remove(processorThread.Key);
					}
				}
				Thread.Sleep(100);
			}
			_processorThreads = null;
			base.OnStop();
		}
protected override void OnStop ( ) { for ( bool firstPass = true ; _processorThreads != null && _processorThreads . Count != 0 ; firstPass = false ) { foreach ( KeyValuePair < Thread , ServiceProcessorBase > processorThread in _processorThreads . ToArray ( ) ) { if ( firstPass && processorThread . Key . IsAlive ) { Log . Info ( " " , ( string . IsNullOrWhiteSpace ( processorThread . Key . Name ) ? processorThread . Key . ManagedThreadId . ToString ( ) : processorThread . Key . Name ) ) ; } if ( ! processorThread . Key . IsAlive || processorThread . Key . Join ( 10 ) ) { processorThread . Value . Dispose ( ) ; _processorThreads . Remove ( processorThread . Key ) ; } } Thread . Sleep ( 100 ) ; } _processorThreads = null ; base . OnStop ( ) ; }
Executes when a Stop command is sent to the service by the Service Control Manager (SCM).
Executes when a Stop command is sent to the service by the Service Control Manager ( SCM ) .
// Iterate through an array copy to allow the removal of objects from the list.