Avatar of Dnx_7
Dnx_7
Flag 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.
C#.NET ProgrammingVisual Basic.NET

Avatar of undefined
Last Comment
Nasir Razzaq

8/22/2022 - Mon
Nasir Razzaq

Yes. You can use any approach.
QueueUserWorkItem works as well.
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
Nasir Razzaq

Your help has saved me hundreds of hours of internet surfing.
fblack61
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
Nasir Razzaq

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question