queue - How to set max number of threads running concurrently using ThreadPool in .NET -


i need execute fixed number of threads,say 5, in parallel, , en-queue remaining threads. here piece of code tried.

threadpool.setmaxthreads(5, 0);  threadpool.queueuserworkitem(new waitcallback(threadproc), task1);             thread.sleep(1000);//'threadproc' callback function 

now, when i'm trying run, 7 threads in parallel running threads simultaneously instead of running 5 thread , queuing next 2 threads. how achieve this?

if can use parallel for/foreach have paralleloptions.maxdegreeofparallelism limit number of concurrent operations.


Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -