/// <summary> /// Ends an asynchronous operation to resolve the <see cref="System.Net.IPHostEntry"/> /// instance for a host or address. /// </summary> /// <param name="iar">The asynchronous operation result.</param> /// <returns>An <see cref="System.Net.IPHostEntry"/> containing information /// associated with the host.</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.Resolvers.DnsResovler.EndGetHostEntry(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 IPHostEntry EndGetHostEntry(IAsyncResult iar) { Guard.NotNull(iar, "iar"); GetHostEntryAsyncState state = iar as GetHostEntryAsyncState; if (state == null) { throw Guard.InvalidAsyncResult("iar"); } state.OnEndCalled(); return(state.Result); }
/// <summary> /// Begins an asynchronous operation to resolve the /// <see cref="System.Net.IPHostEntry"/> for the specified /// <see cref="System.Net.IPAddress"/>. /// </summary> /// <param name="address">The host's IP address.</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="address"/> is <see langword="null"/>. /// </exception> public virtual IAsyncResult BeginGetHostEntry(IPAddress address, AsyncCallback callback, object state) { Guard.NotNull(address, "address"); GetHostEntryAsyncState asyncState = new GetHostEntryAsyncState(callback, state); asyncState.QueueOperation(delegate { try { asyncState.Result = GetHostEntry(address); } catch (DnsException exc) { asyncState.Exception = exc; } finally { asyncState.OnComplete(); } }); return(asyncState); }