PingCompletedEventArgs.Reply Propiedad

Definición

Obtiene un objeto que contiene datos que describen un intento de enviar un mensaje de solicitud de eco del Protocolo de mensajes de control de Internet (ICMP) y recibir un mensaje de respuesta de eco ICMP correspondiente.Gets an object that contains data that describes an attempt to send an Internet Control Message Protocol (ICMP) echo request message and receive a corresponding ICMP echo reply message.

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

Valor de propiedad

PingReply

Objeto PingReply que describe los resultados de la solicitud de eco ICMP.A PingReply object that describes the results of the ICMP echo request.

Ejemplos

En el ejemplo de código siguiente se implementa un método que se utiliza para responder a un PingCompleted evento.The following code example implements a method that is used to respond to a PingCompleted event. Para obtener el ejemplo completo, consulte la PingCompletedEventArgs información general de la clase.For the complete example, see the PingCompletedEventArgs class overview.

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.
      (dynamic_cast<AutoResetEvent^>(e->UserState))->Set();
   }

   
   // If an error occurred, display the exception to the user.
   if ( e->Error != nullptr )
   {
      Console::WriteLine( "Ping failed:" );
      Console::WriteLine( e->Error->ToString() );
      
      // Let the main thread resume. 
      (dynamic_cast<AutoResetEvent^>(e->UserState))->Set();
   }

   PingReply ^ reply = e->Reply;
   DisplayReply( reply );
   
   // Let the main thread resume.
   (dynamic_cast<AutoResetEvent^>(e->UserState))->Set();
}


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

Comentarios

Si el valor de Status no es Success , no debe utilizar los valores devueltos por las RoundtripTime propiedades, Options y Buffer .If the value of Status is not Success, you should not use the values that are returned by the RoundtripTime, Options, and Buffer properties. Las RoundtripTime Buffer propiedades y devolverán cero y la Options propiedad devolverá null .The RoundtripTime and Buffer properties will return zero, and the Options property will return null.

Se aplica a