mirror of
https://github.com/S7NetPlus/s7netplus.git
synced 2026-02-17 22:38:27 +08:00
IsAvailable disposes Ping properly (Issue #32).
Signed-off-by: Michele Cattafesta <michele.cattafesta@mesta-automation.com>
This commit is contained in:
@@ -26,9 +26,19 @@ namespace S7.Net
|
||||
{
|
||||
get
|
||||
{
|
||||
Ping ping = new Ping();
|
||||
PingReply result = ping.Send(IP);
|
||||
return result != null && result.Status == IPStatus.Success;
|
||||
using (Ping ping = new Ping())
|
||||
{
|
||||
PingReply result;
|
||||
try
|
||||
{
|
||||
result = ping.Send(IP);
|
||||
}
|
||||
catch (PingException)
|
||||
{
|
||||
result = null;
|
||||
}
|
||||
return result != null && result.Status == IPStatus.Success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user