Link to home
Start Free TrialLog in
Avatar of Dnx_7
Dnx_7Flag for Belgium

asked on

Task parallel with C#

Hi experts,

i have infinite loop to do misc jobs

with .NET 2.0, i used  thread.QueueUserWorkItem but since .NET 4.0, i use task with :

Task.Factory.StartNew(void(), null);

It works but i read some article that the "task.factory.startnew()" use the new threadpool shipped with .net 4 and this is not for infinite loop because the threadpool can run out of free slot.

that's why i would like to use something that is optimize for multicore programming
do the old "thread.start()" is stilll good to use for multicore programming?

thank you.
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Yes. You can use any approach.
QueueUserWorkItem works as well.
Avatar of Dnx_7

ASKER

thank you but i read that the "queueuserworkitem" should be avoided since .NET 4
because it uses the "old" threadpool not the new one shipped with the last framework...

am i wrong?

thank you
Avatar of Dnx_7

ASKER

Thank you codecruiser, i read again some articles and here what i understood :

when you compile your app in the framework 2.0, it will use the "old" threadpool shipped with that framework.

When you compile in 3.5 or 4.0, it will use the new threadpool that is optimized for TASK/Parallel and seems that will the QueueUserWorkItem, it has been optimized too for multicore machine

am i right?
ASKER CERTIFIED SOLUTION
Avatar of Nasir Razzaq
Nasir Razzaq
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial