private void EnqueueConcurrent(Int32 queueingThreads, Int32 tasksPerThread, Object task)
 {
     for (Int32 i = 0; i < queueingThreads; i++)
     {
         Thread         queueingThread = new Thread(new ParameterizedThreadStart(EnqueueTasksThreadFunc));
         EnqueingObject enqueueObj     = new EnqueingObject()
         {
             Task = task, TasksToEnqueue = tasksPerThread
         };
         queueingThread.Start(enqueueObj);
     }
 }
        public static void EnqueueTasksThreadFunc(Object state)
        {
            EnqueingObject enqueueObj = state as EnqueingObject;

            if (enqueueObj == null)
            {
                throw new ArgumentNullException();
            }

            for (Int32 i = 0; i < enqueueObj.TasksToEnqueue; i++)
            {
                // If this isn't a real ITask, a run-time exception will be thrown.
                BlockingTaskQueue.TaskQueue.Enqueue((ITask)enqueueObj.Task);
            }
        }
Esempio n. 3
0
 private void EnqueueConcurrent(Int32 queueingThreads, Int32 tasksPerThread, Object task)
 {
     for (Int32 i = 0; i < queueingThreads; i++)
     {
         Thread queueingThread = new Thread(new ParameterizedThreadStart(EnqueueTasksThreadFunc));
         EnqueingObject enqueueObj = new EnqueingObject() { Task = task, TasksToEnqueue = tasksPerThread };
         queueingThread.Start(enqueueObj);
     }
 }