void DoWork(object info) { MegaCachePointTaskInfo inf = (MegaCachePointTaskInfo)info; while (isRunning) { inf.pauseevent.WaitOne(Timeout.Infinite, false); //if ( inf.end > 0 ) //PreLoad(inf.frame, inf.objcache); inf.end = 0; // Done the job } }
void MakeThreads(MegaCachePointCloudXYZ cache) { if (Cores > 0) { isRunning = true; tasks = new MegaCachePointTaskInfo[Cores]; for (int i = 0; i < Cores; i++) { tasks[i] = new MegaCachePointTaskInfo(); tasks[i].objcache = cache; tasks[i].name = "ThreadID " + i; tasks[i].pauseevent = new AutoResetEvent(false); tasks[i]._thread = new Thread(DoWork); tasks[i]._thread.Start(tasks[i]); } } }