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

libGdx unable to find files in android application data directory -

php - Webix Data Loading from Laravel Link -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -