M
M
mad_god2017-06-17 15:04:09
Computer networks
mad_god, 2017-06-17 15:04:09

What is the upper limit of C# asynchronous ping rate?

I'm trying to figure out async await using asynchronous ping as an example.
First I create 400 IP addresses, then I queue 400 asynchronous tasks
The program runs for about a minute and it seems to me that this is not a performance limit, I think you can ping 400 addresses in a second, not a minute.
It looks like await waits for the result of each ping in turn, without switching to those that have already completed.
In general, confused.
https://pastebin.com/Yh3m3v2Y

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
LiptonOlolo, 2017-06-19
@LiptonOlolo

Use Parallel.For instead of foreach, so at least reduce the execution by 2 times.
Here is an example and do not be surprised that the numbers are inconsistent.
And I didn’t quite understand where you have asynchrony there, everything seems to be done in the GUI thread, if you need full asynchrony, then it’s better to use Task.Run(() => { ... }); for each IP.
Oh yeah, just writing an async method doesn't mean it's asynchronous.
To make it completely asynchronous, you need something like this:
YmEVqPns064qq2.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question