コード例 #1
0
        public void GetAddressAsync(string name)
        {
            GetAddressDelegate dc = new GetAddressDelegate(this.GetAddress);

            AsyncCallback cb = new AsyncCallback(this.GetResultsOnCallback);
            IAsyncResult  ar = dc.BeginInvoke(name, cb, null);
        }
コード例 #2
0
        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);
            }
        }