1

I have some question about using queues and threads. I already made researches, but I don't manage to understand the general functionnement.

What I want to do : I have a class, named "mTask", in which there are properties and a method, called "StartmTask". When I create a new mTask, I add it to a List .

And I want to process the mTask, when there are mTasks in the list. ( I have to launch a task on each free processor of the computer)

I don't understand how I should do... I think this is "simple" but I am actually lost. Is any one would be able to explain it as simply as possible ?

Thanks a lot, I keep searching, if I am not clear enough, or if you need more information, don't hesitate to ask.

Yowan

slugster
  • 49,403
  • 14
  • 95
  • 145
Yowan
  • 15
  • 2
  • http://stackoverflow.com/questions/3872992/how-do-we-do-idle-time-processing-in-wpf-application – spender Feb 17 '11 at 10:00

1 Answers1

0

I think probably the best and simplest solution would be to put the mTask to the ThreadPool instead of an list which you would have to observe.

Have a look at the method

ThreadPool.QueueUserWorkItem

Example:

ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), )mTask);

private void DoWork(object o)
{
    task = o;
}

If you use it, without any settings, the Threads are assigned to every cpu. You don't have to care about that.

BitKFu
  • 3,649
  • 3
  • 28
  • 43