Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

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:
property PingReply^ Reply {
	PingReply^ get();
}

Property Value

Type: System.Net.NetworkInformation::PingReply^

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 RoundtripTime and Buffer properties will return zero, and the Options property will return null.

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.

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


.NET Framework
Available since 2.0
Return to top
Show:
© 2017 Microsoft