IPGlobalProperties.GetUnicastAddressesAsync 方法

定義

以非同步作業的方式,從本機電腦擷取穩定單點傳播 IP 位址表格。

public:
 virtual System::Threading::Tasks::Task<System::Net::NetworkInformation::UnicastIPAddressInformationCollection ^> ^ GetUnicastAddressesAsync();
public virtual System.Threading.Tasks.Task<System.Net.NetworkInformation.UnicastIPAddressInformationCollection> GetUnicastAddressesAsync ();
abstract member GetUnicastAddressesAsync : unit -> System.Threading.Tasks.Task<System.Net.NetworkInformation.UnicastIPAddressInformationCollection>
override this.GetUnicastAddressesAsync : unit -> System.Threading.Tasks.Task<System.Net.NetworkInformation.UnicastIPAddressInformationCollection>
Public Overridable Function GetUnicastAddressesAsync () As Task(Of UnicastIPAddressInformationCollection)

傳回

工作物件,表示非同步作業。

例外狀況

呼叫原生 GetAdaptersAddresses 函式失敗。

呼叫端沒有必要的 Read 權限。

呼叫原生 NotifyStableUnicastIpAddressTable 函式失敗。

備註

為了支援輸出連線或接受 Teredo 介面上的連入連線,應用程式必須確定 Teredo 介面已啟動並可供使用。 這是因為 Teredo 可以在未使用一段時間時進入休眠狀態。

方法 GetUnicastAddressesAsync 可讓應用程式擷取穩定單播 IP 位址的清單作為非同步作業。 IPAddress.IsIPv6Teredo屬性可用來判斷 IP 位址是否為前置詞為 2001::/32 的 IPv6 Teredo 位址。

方法 GetUnicastAddresses 也會傳回非 Teredo 位址,並提供更方便的方式來取得系統的單播 IP 位址,而不是列舉本機電腦上的所有 System.Net.NetworkInformation.NetworkInterface 物件,以及查詢相關聯的 IP 位址。

適用於

另請參閱