Ping.PingCompleted 事件

定义

当发送 Internet 控制消息协议 (ICMP) 回送消息并接收相应 ICMP 回送答复消息的异步操作完成或被取消时发生。Occurs when an asynchronous operation to send an Internet Control Message Protocol (ICMP) echo message and receive the corresponding ICMP echo reply message completes or is canceled.

public:
 event System::Net::NetworkInformation::PingCompletedEventHandler ^ PingCompleted;
public event System.Net.NetworkInformation.PingCompletedEventHandler PingCompleted;
member this.PingCompleted : System.Net.NetworkInformation.PingCompletedEventHandler 
Public Event PingCompleted As PingCompletedEventHandler 

示例

下面的代码示例演示如何为 PingCompleted 事件指定回调方法。The following code example demonstrates specifying a callback method for the PingCompleted event. Ping 类概述中提供了完整的示例。The complete example is available in the Ping class overview.

Ping ^ pingSender = gcnew Ping;

// When the PingCompleted event is raised,
// the PingCompletedCallback method is called.
pingSender->PingCompleted += gcnew PingCompletedEventHandler( PingCompletedCallback );

Ping pingSender = new Ping ();

// When the PingCompleted event is raised,
// the PingCompletedCallback method is called.
pingSender.PingCompleted += new PingCompletedEventHandler (PingCompletedCallback);

注解

应用程序使用 PingCompleted 事件获取有关完成状态的信息以及通过调用其中一个 SendAsync 方法收集的数据。Applications use the PingCompleted event to get information about the completion status and data collected by a call to one of the SendAsync methods. PingCompletedEventHandler 委托提供 SendAsync 引发此事件时调用的回调方法。The PingCompletedEventHandler delegate provides the call back method invoked when SendAsync raises this event.

适用于