/// <summary> /// Ends an asynchronous operation to resolve the <see cref="AK.Net.Dns.MXInfo"/> /// instance for a domain. /// </summary> /// <param name="iar">The asynchronous operation result.</param> /// <returns>The mail exchange information associated with the 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.Resolvers.DnsResovler.EndGetMXInfo(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 MXInfo EndGetMXInfo(IAsyncResult iar) { Guard.NotNull(iar, "iar"); GetMXInfoAsyncState state = iar as GetMXInfoAsyncState; if (state == null) { throw Guard.InvalidAsyncResult("iar"); } state.OnEndCalled(); return(state.Result); }
/// <summary> /// Begins an asynchronous operation to resolve the <see cref="AK.Net.Dns.MXInfo"/> /// instance 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 BeginGetMXInfo(DnsName domain, AsyncCallback callback, object state) { Guard.NotNull(domain, "domain"); GetMXInfoAsyncState asyncState = new GetMXInfoAsyncState(callback, state); asyncState.QueueOperation(delegate { try { asyncState.Result = GetMXInfo(domain); } catch (DnsException exc) { asyncState.Exception = exc; } finally { asyncState.OnComplete(); } }); return(asyncState); }