Jitter.ThreadManager.Initialize C# (CSharp) Method

Initialize() private method

private Initialize ( ) : void
return void
        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();
            }



        }

Usage Example

Ejemplo n.º 1
0
 internal static void InitializeInstance()
 {
     if (internalInstance == null)
     {
         internalInstance = new ThreadManager();
         internalInstance.Initialize();
     }
 }