dWorld.Foundation.Utility.Threading.dLightWeightProcessThread.Quit C# (CSharp) Method

Quit() public static method

public static Quit ( ) : void
return void
		public static void Quit ()
		{
			lock (m_Lock) {
				// if we only have one ref count 
				// destroy all the service threads
				// else just decrement the refrence
				// counter.
				if (m_nRefCount == 1) {
					if (m_Threads != null) {
						// Set the thread to drop through.
						ThreadProcess.m_Stop.Set ();
						foreach (Thread thread in m_Threads)
							thread.Join ();
						m_Threads = null;

						// Unregister all the nodes.
						foreach (MPCList<dLightWeightProcessBase>.Node node in m_Processes) {
							node.Data.internal_DecrementRegister ();
							node.Data.internal_UnRegister ();
						}
						m_Processes = null;

						ThreadProcess.Term ();
					}
				}
				// Prevent the count going below 0
				m_nRefCount = Math.Max (m_nRefCount - 1, 0);
			}
		}
	}