A
A
AlexEternal2018-10-26 16:28:26
C++ / C#
AlexEternal, 2018-10-26 16:28:26

How to control the number of threads in C#?

Hello.
The problem is that you need to manage the number of threads. That is, the task is the following, for example, start 5 threads out of 5 threads finished 1. So the other 4 threads work to the end, but we create another thread and add it to the pool. How to manage flows? Where to look in terms of implementation?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexander Yudakov, 2018-10-26
@AlexEternal

Everything has already been implemented: https :
//docs.microsoft.com/ru-ru/dotnet/api/system... dotnet/api/system... https://docs.microsoft.com/en-us/dotnet/api/system...

A
alex_ak1, 2018-10-26
@alex_ak1

One thread finished and ticked "I'm all". The control thread saw the checkbox and started another thread.
The checkbox can be replaced with a semaphore.

G
Griboks, 2018-10-26
@Griboks

Have a look System.Threading.ThreadPooland System.Threading.Tasks.Parallel(or PLINQ).
Or just write your own. This classic puzzle will take no more than 30 minutes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question