Click or drag to resize

Pinger Class

Implements a threadsafe subset of the .NET Framework Ping class.
Inheritance Hierarchy
SystemObject
  Neon.NetPinger

Namespace:  Neon.Net
Assembly:  Neon.Common (in Neon.Common.dll) Version: 2.1.0
Syntax
public class Pinger : IDisposable

The Pinger type exposes the following members.

Constructors
  NameDescription
Public methodPinger
Constructor.
Top
Methods
  NameDescription
Public methodClear
Disposes any unused underlying Ping instances.
Public methodDispose
Releases all resources associated with the instance.
Protected methodDispose(Boolean)
Releases all associated resources.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Finalizer.
(Overrides ObjectFinalize.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodSendPingAsync(IPAddress, Int32)
Pings a IP address.
Public methodSendPingAsync(String, Int32)
Pings a IP address passed as a string.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Remarks

Unfortunately, the .NET Framework Ping class is not threadsafe (even the async methods). So, we need to ensure that only one ping request is performed on any given instance.

My original idea was to simply create and dispose Ping] instances on the fly for each request, but I changed my mind after thinking about the potential performance overhead as well as the potential for exhausting ephemeral socket ports.

Instead, I'm going to maintain a queue of Ping instances that that can be reused for subsequent queries.

Thread Safety
Instance members of this type are safe for multi-threaded operations.
See Also