private static void ThreadWorker(object obj) { NavMeshTemplateRecast template = (NavMeshTemplateRecast)obj; try { template.Work(); } catch (Exception e) { if (template.profiler != null) { template.profiler.DebugLog(ProfilderLogMode.warning); } Debug.LogError(e); throw; } }
private static IEnumerator TemplatePopulationLoop() { NavMeshTemplateRecast nm_t = null; while (true) { //if (_disconnectionQueue.Count > 0) // Debug.Log("NavMeshTemplateRecast blocked by _disconnectionQueue.Count > 0"); if (_acceptingWork == false | _activeThreads >= _settings.maxThreads | _disconnectionQueue.Count > 0) { goto next; } lock (_navMeshTemplateQueue) nm_t = _navMeshTemplateQueue.Count > 0 ? _navMeshTemplateQueue.Dequeue() : null; if (nm_t == null) { goto next; } _activeCreationWorks++; nm_t.Populate(); if (multithread) { ThreadPool.QueueUserWorkItem(new WaitCallback(ThreadWorker), nm_t); _activeThreads++; //increasing thread count but it's not really a thread. it's whole operation until connection } else { nm_t.Work(); } //Debug.LogFormat("taken {0}, now active creation is {1}", "NavMeshTemplateRecast", _activeCreationWorks); goto next; next: { yield return(new WaitForEndOfFrame()); continue; } } }