public static IAsyncResult BeginResolve (String hostName, AsyncCallback requestedCallback, Object stateObject) { // TODO DnsAsyncResult result = new DnsAsyncResult(requestedCallback, stateObject, DnsOperation.Resolve); result.BeginInvoke(hostName); return((IAsyncResult)(result)); }
static void OnCompleted(object sender, SimpleResolverEventArgs e) { DnsAsyncResult ares = (DnsAsyncResult)e.UserToken; IPHostEntry entry = e.HostEntry; if (entry == null || e.ResolverError != 0) { ares.SetCompleted(false, new Exception("Error: " + e.ResolverError)); return; } ares.SetCompleted(false, entry); }
static IAsyncResult BeginAsyncCallAddresses(string host, AsyncCallback callback, object state) { SimpleResolverEventArgs e = new SimpleResolverEventArgs(); e.Completed += OnCompleted; e.HostName = host; DnsAsyncResult ares = new DnsAsyncResult(callback, state); e.UserToken = ares; if (resolver.GetHostAddressesAsync(e) == false) { ares.SetCompleted(true, e.HostEntry); // Completed synchronously } return(ares); }
static IPHostEntry EndAsyncCall(DnsAsyncResult ares) { if (ares == null) { throw new ArgumentException("Invalid asyncResult"); } if (!ares.IsCompleted) { ares.AsyncWaitHandle.WaitOne(); } if (ares.Exception != null) { throw ares.Exception; } IPHostEntry entry = ares.HostEntry; if (entry == null || entry.AddressList == null || entry.AddressList.Length == 0) { Error_11001(entry.HostName); } return(entry); }
static IAsyncResult BeginAsyncCall (string host, AsyncCallback callback, object state) { SimpleResolverEventArgs e = new SimpleResolverEventArgs (); e.Completed += OnCompleted; e.HostName = host; DnsAsyncResult ares = new DnsAsyncResult (callback, state); e.UserToken = ares; if (resolver.GetHostEntryAsync (e) == false) ares.SetCompleted (true, e.HostEntry); // Completed synchronously return ares; }
static IPHostEntry EndAsyncCall (DnsAsyncResult ares) { if (ares == null) throw new ArgumentException ("Invalid asyncResult"); if (!ares.IsCompleted) ares.AsyncWaitHandle.WaitOne (); if (ares.Exception != null) throw ares.Exception; IPHostEntry entry = ares.HostEntry; if (entry == null || entry.AddressList == null || entry.AddressList.Length == 0) throw new SocketException(11001); return entry; }
public static IAsyncResult BeginResolve (String hostName, AsyncCallback requestedCallback, Object stateObject) { // TODO DnsAsyncResult result=new DnsAsyncResult(requestedCallback, stateObject,DnsOperation.Resolve); result.BeginInvoke(hostName); return (IAsyncResult) (result); }
static void CB(object _this) { DnsAsyncResult ares = (DnsAsyncResult)_this; ares.callback(ares); }