Example #1
0
        private static void AddTaskToPool(TaskHandle taskHandle)
        {
            DistributedThread handler = new DistributedThread(TaskBody);

            if (_pool.Count < Environment.ProcessorCount)
            {
                handler.ProcessorAffinity = 1 << _pool.Count;
            }

            handler.ManagedThread.Name         = "Thread Pool Thread";
            handler.ManagedThread.IsBackground = true;

            TaskItem taskItem = new TaskItem(taskHandle, handler);

            taskItem.Handler.Start(taskItem);

            lock (_poolLock)
            {
                _pool.Add(taskItem);
            }
        }
Example #2
0
 public TaskItem(TaskHandle handle, DistributedThread handler)
 {
     Handle  = handle;
     Handler = handler;
     State   = TaskState.NotStarted;
 }