Бөлісу құралы:


PingCompletedEventArgs.Reply Свойство

Определение

Возвращает объект, содержащий данные, описывающие попытку отправить сообщение запроса на эхо-сообщение протокола ICMP и получение соответствующего сообщения ответа на эхо-сообщение ICMP.

public:
 property System::Net::NetworkInformation::PingReply ^ Reply { System::Net::NetworkInformation::PingReply ^ get(); };
public System.Net.NetworkInformation.PingReply? Reply { get; }
public System.Net.NetworkInformation.PingReply Reply { get; }
member this.Reply : System.Net.NetworkInformation.PingReply
Public ReadOnly Property Reply As PingReply

Значение свойства

PingReply Объект, описывающий результаты эхо-запроса ICMP.

Примеры

В следующем примере кода реализуется метод, используемый для реагирования на PingCompleted событие. Полный пример см. в обзоре PingCompletedEventArgs класса.

private static void PingCompletedCallback (object sender, PingCompletedEventArgs e)
{
    // If the operation was canceled, display a message to the user.
    if (e.Cancelled)
    {
        Console.WriteLine ("Ping canceled.");

        // Let the main thread resume.
        // UserToken is the AutoResetEvent object that the main thread
        // is waiting for.
        ((AutoResetEvent)e.UserState).Set ();
    }

    // If an error occurred, display the exception to the user.
    if (e.Error != null)
    {
        Console.WriteLine ("Ping failed:");
        Console.WriteLine (e.Error.ToString ());

        // Let the main thread resume.
        ((AutoResetEvent)e.UserState).Set();
    }

    PingReply reply = e.Reply;

    DisplayReply (reply);

    // Let the main thread resume.
    ((AutoResetEvent)e.UserState).Set();
}

Комментарии

Если значение Status не имеет значения, не следует использовать значения, возвращаемые свойствами и Buffer свойствамиRoundtripTimeOptions.Success Свойства RoundtripTime возвращают ноль, а Options свойство возвращаетсяnull.Buffer

Применяется к