public void GetAddressAsync(string name) { GetAddressDelegate dc = new GetAddressDelegate(this.GetAddress); AsyncCallback cb = new AsyncCallback(this.GetResultsOnCallback); IAsyncResult ar = dc.BeginInvoke(name, cb, null); }
public void GetAddressAsyncWait(string name) { GetAddressDelegate dc = new GetAddressDelegate(this.GetAddress); IAsyncResult ar = dc.BeginInvoke(name, null, null); // Main thread can in principle do other work now try { string result = dc.EndInvoke(ar); Console.WriteLine("\nAsync waiting : " + result); } catch (Exception ex) { Console.WriteLine("\nAsync waiting, a problem occurred : " + ex.Message); } }