public void RequestMeshData(System.Action <ChunkMeshData[]> callback, ChunkColumn chunkCol, int yIndex) { ThreadMeshObject threadTask = new ThreadMeshObject(callback, chunkCol, yIndex); ThreadPool.QueueUserWorkItem(new WaitCallback(MeshDataThread), threadTask); amountOfWorkerThreads++; }
public void MeshDataThread(object threadTask) { ThreadMeshObject threadTaskInfo = (ThreadMeshObject)threadTask; try { ChunkMeshData[] chunkMeshData = World.meshGen.GenerateChunkMeshData(threadTaskInfo.chunkCol, threadTaskInfo.yIndex); ThreadMeshInfo threadInfo = new ThreadMeshInfo(threadTaskInfo.callback, chunkMeshData); lock (threadMeshQueue) { threadMeshQueue.Enqueue(threadInfo); } } catch { Debug.Log("Chunk Mesh Error Occured!"); } }