T
T
tefoxis2020-08-04 15:24:43
C++ / C#
tefoxis, 2020-08-04 15:24:43

C#. What is better to use to execute a function in 10 threads?

Hello!
What is better to use to execute a function in 10 threads?
In general, there are 7000 lines, for each of these lines it is necessary to execute the function roughly speaking CheckThis (string request)
I want to speed up this business so that 10 requests are executed at once.
What is better to use for this? Parallels.Foreach? threads? Plinq?

Thanks in advance.

PS If it's not difficult, tell me a mini example. Thanks

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Mirilaczvili, 2020-08-04
@tefoxis

Parallel.For(0, 1000, new ParallelOptions { MaxDegreeOfParallelism = 10 },
  i =>
  {
    GetPage(pageList[i]);
  });

https://stackoverflow.com/questions/10342057/c-sha...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question