public PoolWorker(DedicatedThreadPool pool, int workerId)
            {
                _pool       = pool;
                _threadExit = new TaskCompletionSource <object>();

                var thread = new Thread(RunThread, pool.Settings.ThreadMaxStackSize);

                thread.IsBackground = pool.Settings.ThreadType == ThreadType.Background;

                if (pool.Settings.Name != null)
                {
                    thread.Name = string.Format("{0}_{1}", pool.Settings.Name, workerId);
                }

                if (pool.Settings.ApartmentState != ApartmentState.Unknown)
                {
                    thread.SetApartmentState(pool.Settings.ApartmentState);
                }

                thread.Start();
            }
 public DedicatedThreadPoolTaskScheduler(DedicatedThreadPool pool)
 {
     _pool = pool;
 }