共用方式為


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值不是 Success,你就不應該使用由 、 OptionsBuffer 屬性所回傳RoundtripTime的值。 RoundtripTimeBuffer屬性將回傳零,Options而屬性則返回 null

適用於