The first thing I would recommend in this case is to use one of the blocks:
This will protect against unforeseen situations, for example, when an exception is thrown out.
The second thing I would advise is the use of the asynchronous version of the Send method. I'm not sure that it is precisely after 190 attempts that everything should become so critical, but I dare to suggest this correction. Best of all, set a timeout (longer than the default timeout for the Ping command), and then call SendAsyncCancel to cancel all pending asynchronous requests before sending SendAsync . You can familiarize yourself with the Ping class and its methods and properties here: the Ping class of the System.Net.NetworkInformation namespace. I also strongly recommend that you read the Comments section of this article. And this will not be superfluous: The Internet Engineering Task Force
Also, I do not recommend creating multiple instances of the type:
System.Net.NetworkInformation.Ping
If this code block is looped, then move the ping variable out of this block and use only one instance. Somewhere I stumbled upon an article that had a similar problem and was accompanied by a memory leak.