Condividi tramite


PingCompletedEventArgs.Reply Proprietà

Definizione

Ottiene un oggetto contenente dati che descrivono un tentativo di invio di un messaggio di richiesta echo ICMP (Internet Control Message Protocol) e di ricezione di un messaggio di risposta echo ICMP corrispondente.

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

Valore della proprietà

Oggetto PingReply che descrive i risultati della richiesta echo ICMP.

Esempio

Nell'esempio di codice seguente viene implementato un metodo usato per rispondere a un PingCompleted evento. Per l'esempio completo, vedere panoramica della PingCompletedEventArgs classe.

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();
}

Commenti

Se il valore di Status non Successè , non è consigliabile usare i valori restituiti dalle RoundtripTimeproprietà , Optionse Buffer . Le RoundtripTime proprietà e Buffer restituiranno zero e la Options proprietà restituirà null.

Si applica a