語言

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 位址,並提供比在本地電腦枚舉所有 System.Net.NetworkInformation.NetworkInterface 物件並查詢相關 IP 位址更方便的方式取得系統的單播 IP 位址。

此方法在任務中儲存所有非使用例外,該方法的同步對應程式可拋出這些例外。 如果回傳的任務中儲存了例外,該例外會在等待任務時拋出。 使用例外錯誤,例如 ArgumentException,仍會同步拋出。 關於儲存的例外,請參見由 GetUnicastAddresses()拋出的例外。

適用於

另請參閱