This documentation is archived and is not being maintained.

PingCompletedEventArgs.Reply Property

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.

Namespace: System.Net.NetworkInformation
Assembly: System (in system.dll)

public PingReply Reply { get; }
/** @property */
public PingReply get_Reply ()

public function get Reply () : PingReply

Not applicable.

Property Value

A PingReply object that describes the results of the ICMP echo request.

If the value of Status is not Success, you should not use the values that are returned by the RoundTripTime, Options, and Buffer properties. The PP:System.Net.NetworkInformation.PingReply.RoundTripTime and Buffer properties will return zero, and the Options property will return a null reference (Nothing in Visual Basic).

The following code example implements a method that is used to respond to a PingCompleted event. For the complete example, see the PingCompletedEventArgs class overview.

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


Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: