/// <summary> /// Begins an asynchronous operation to resolve a /// <see cref="System.Net.IPHostEntry"/> for each of the authoritative name /// servers for a domain. /// </summary> /// <param name="iar">The asynchronous operation result.</param> /// <returns> /// The list of <see cref="AK.Net.Dns.DnsName"/> instances for each of the /// authoritative name servers for the specified <paramref name="domain"/>. /// </returns> /// <exception cref="System.ArgumentNullException"> /// Thrown when <paramref name="iar"/> is <see langword="null"/>. /// </exception> /// <exception cref="System.ArgumentException"> /// Thrown when the specified async result does not belong to this operation. /// </exception> /// <exception cref="System.InvalidOperationException"> /// Thrown when /// <see cref="M:AK.Net.Dns.IDnsResovler.EndGetNameServers(System.IAsyncResult)"/> /// has already been called on the specified async result. /// </exception> /// <exception cref="AK.Net.Dns.DnsTransportException"> /// Thrown when a transport error occurred during the asynchronous operation. /// </exception> /// <exception cref="AK.Net.Dns.DnsResolutionException"> /// Thrown when an error occurred during the resolution, such as the query /// not being answered. /// </exception> public virtual DnsName[] EndGetNameServers(IAsyncResult iar) { Guard.NotNull(iar, "iar"); GetNameServersAsyncState state = iar as GetNameServersAsyncState; if (state == null) { throw Guard.InvalidAsyncResult("iar"); } state.OnEndCalled(); return(state.Result); }
/// <summary> /// Begins an asynchronous operation to resolve a <see cref="AK.Net.Dns.DnsName"/> /// instance for each of the authoritative name servers for the specified /// <paramref name="domain"/>. /// </summary> /// <param name="domain">The domain name.</param> /// <param name="callback">The method to invoke once the asynchronous operation /// has completed.</param> /// <param name="state">The user-defined state object to associate with the /// asynchronous operation.</param> /// <returns>The asynchronous operation result.</returns> /// <exception cref="System.ArgumentNullException"> /// Thrown when <paramref name="domain"/> is <see langword="null"/>. /// </exception> public virtual IAsyncResult BeginGetNameServers(DnsName domain, AsyncCallback callback, object state) { Guard.NotNull(domain, "domain"); GetNameServersAsyncState asyncState = new GetNameServersAsyncState(callback, state); asyncState.QueueOperation(delegate { try { asyncState.Result = GetNameServers(domain); } catch (DnsException exc) { asyncState.Exception = exc; } finally { asyncState.OnComplete(); } }); return(asyncState); }