private void Initialize()
{
#if XBOX
ThreadCount = xBoxMap.Length;
#elif WINDOWS_PHONE
ThreadCount = 2;
#else
threadCount = System.Environment.ProcessorCount * ThreadsPerProcessor;
#endif
threads = new Thread[threadCount];
waitHandleA = new ManualResetEvent(false);
waitHandleB = new ManualResetEvent(false);
currentWaitHandle = waitHandleA;
AutoResetEvent initWaitHandle = new AutoResetEvent(false);
for (int i = 1; i < threads.Length; i++)
{
threads[i] = new Thread(() =>
{
#if XBOX
Thread.CurrentThread.SetProcessorAffinity(xBoxMap[i]);
#endif
initWaitHandle.Set();
ThreadProc();
});
threads[i].IsBackground = true;
threads[i].Start();
initWaitHandle.WaitOne();
}
}