/// <summary> /// Ends an asynchronous operation to send the a <see cref="AK.Net.Dns.DnsQuery"/> /// to an end point and return the <see cref="AK.Net.Dns.DnsReply"/>. /// </summary> /// <param name="iar">The asynchronous operation result.</param> /// <returns> /// The <see cref="AK.Net.Dns.DnsReply"/> to the <see cref="AK.Net.Dns.DnsQuery"/>. /// </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="AK.Net.Dns.IDnsTransport.EndSend(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> public virtual DnsReply EndSend(IAsyncResult iar) { Guard.NotNull(iar, "iar"); SendAsyncState state = iar as SendAsyncState; if (state == null) { throw Guard.InvalidAsyncResult("iar"); } state.OnEndCalled(); return(state.Result); }