CSL_Traffic.TPPPathFind.PathFindThread C# (CSharp) Méthode

PathFindThread() private méthode

private PathFindThread ( ) : void
Résultat void
		private void PathFindThread()
	    {
		    while (true)
		    {
			    while (!Monitor.TryEnter(this.m_queueLock, SimulationManager.SYNCHRONIZE_TIMEOUT))
			    {
			    }
			    try
			    {
				    while (this.m_queueFirst == 0u && !this.m_terminated)
				    {
					    Monitor.Wait(this.m_queueLock);
				    }
				    if (this.m_terminated)
				    {
					    break;
				    }
				    this.m_calculating = this.m_queueFirst;
				    this.m_queueFirst = this.m_pathUnits.m_buffer[(int)((UIntPtr)this.m_calculating)].m_nextPathUnit;
				    if (this.m_queueFirst == 0u)
				    {
					    this.m_queueLast = 0u;
					    Facade.m_queuedPathFindCount = 0;
				    }
				    else
				    {
                        Facade.m_queuedPathFindCount--;
				    }
				    this.m_pathUnits.m_buffer[(int)((UIntPtr)this.m_calculating)].m_nextPathUnit = 0u;
				    this.m_pathUnits.m_buffer[(int)((UIntPtr)this.m_calculating)].m_pathFindFlags = (byte)(((int)this.m_pathUnits.m_buffer[(int)((UIntPtr)this.m_calculating)].m_pathFindFlags & -2) | 2);
			    }
			    finally
			    {
				    Monitor.Exit(this.m_queueLock);
			    }
			    try
			    {
                    Facade.m_pathfindProfiler.BeginStep();
				    try
				    {
					    this.PathFindImplementation(this.m_calculating, ref this.m_pathUnits.m_buffer[(int)((UIntPtr)this.m_calculating)]);
				    }
				    finally
				    {
                        Facade.m_pathfindProfiler.EndStep();
				    }
			    }
			    catch (Exception ex)
			    {
				    UIView.ForwardException(ex);
				    CODebugBase<LogChannel>.Error(LogChannel.Core, "Path find error: " + ex.Message + "\n" + ex.StackTrace);
				    PathUnit[] expr_1A0_cp_0 = this.m_pathUnits.m_buffer;
				    UIntPtr expr_1A0_cp_1 = (UIntPtr)this.m_calculating;
				    expr_1A0_cp_0[(int)expr_1A0_cp_1].m_pathFindFlags = (byte)(expr_1A0_cp_0[(int)expr_1A0_cp_1].m_pathFindFlags | 8);
			    }
			    while (!Monitor.TryEnter(this.m_queueLock, SimulationManager.SYNCHRONIZE_TIMEOUT))
			    {
			    }
			    try
			    {
				    this.m_pathUnits.m_buffer[(int)((UIntPtr)this.m_calculating)].m_pathFindFlags = (byte)((int)this.m_pathUnits.m_buffer[(int)((UIntPtr)this.m_calculating)].m_pathFindFlags & -3);
				    Singleton<PathManager>.instance.ReleasePath(this.m_calculating);
				    this.m_calculating = 0u;
				    Monitor.Pulse(this.m_queueLock);
			    }
			    finally
			    {
				    Monitor.Exit(this.m_queueLock);
			    }
		    }
	    }
    }