Ping.PingCompleted 事件

定义

当发送 Internet 控制消息协议 (ICMP) 回送消息并接收相应 ICMP 回送答复消息的异步操作完成或被取消时发生。

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

事件类型

示例

下面的代码示例演示如何为 PingCompleted 事件指定回调方法。 类概述中 Ping 提供了完整的示例。

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 方法收集的数据。 委托 PingCompletedEventHandler 提供引发此事件时 SendAsync 调用的回调方法。

适用于