Но при перехвате исключения невозможно создать новый PingReply?
Код: Выделить всё
PingReply pingReply = null;
try
{
pingReply = await pingSender.SendPingAsync(host, timeout, buffer, options);
}
catch (PingException ex)
{
pingReply = new PingReply();
//other pingReply properties set here, like status success, etc
}
catch (ArgumentNullException) { }
catch (Exception) { throw; }
Код: Выделить всё
#region Assembly System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll
#endregion
namespace System.Net.NetworkInformation
{
//
// Summary:
// Provides information about the status and data resulting from a Overload:System.Net.NetworkInformation.Ping.Send
// or Overload:System.Net.NetworkInformation.Ping.SendAsync operation.
public class PingReply
{
//
// Summary:
// Gets the status of an attempt to send an Internet Control Message Protocol (ICMP)
// echo request and receive the corresponding ICMP echo reply message.
//
// Returns:
// An System.Net.NetworkInformation.IPStatus value indicating the result of the
// request.
public IPStatus Status { get; }
//
// Summary:
// Gets the address of the host that sends the Internet Control Message Protocol
// (ICMP) echo reply.
//
// Returns:
// An System.Net.IPAddress containing the destination for the ICMP echo message.
public IPAddress Address { get; }
//
// Summary:
// Gets the number of milliseconds taken to send an Internet Control Message Protocol
// (ICMP) echo request and receive the corresponding ICMP echo reply message.
//
// Returns:
// An System.Int64 that specifies the round trip time, in milliseconds.
public long RoundtripTime { get; }
//
// Summary:
// Gets the options used to transmit the reply to an Internet Control Message Protocol
// (ICMP) echo request.
//
// Returns:
// A System.Net.NetworkInformation.PingOptions object that contains the Time to
// Live (TTL) and the fragmentation directive used for transmitting the reply if
// System.Net.NetworkInformation.PingReply.Status is System.Net.NetworkInformation.IPStatus.Success;
// otherwise, null.
public PingOptions Options { get; }
//
// Summary:
// Gets the buffer of data received in an Internet Control Message Protocol (ICMP)
// echo reply message.
//
// Returns:
// A System.Byte array containing the data received in an ICMP echo reply message,
// or an empty array, if no reply was received.
public byte[] Buffer { get; }
}
}
Подробнее здесь: https://stackoverflow.com/questions/569 ... t-possible
Мобильная версия