首页 > 其他 > 详细

async

时间:2015-05-23 21:20:41      阅读:139      评论:0      收藏:0      [点我收藏+]
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Xml.Linq;

namespace rooxml
{

    public class main
    {
        public delegate void AsyncEventHandler ();
        [STAThread]
        public static void Main ()
        {
            main m = new main ();
            AsyncEventHandler asy = new AsyncEventHandler(m.Event1);
            IAsyncResult ia = asy.BeginInvoke (null, null);

            m.Event2 ();
            asy.EndInvoke (ia);

        }

        void CallbackMathod(AsyncEventHandler ar){

        }

        void Event1(){
            Console.WriteLine ("e1 is start");
            System.Threading.Thread.Sleep (2000);
            Console.WriteLine ("e1 is end");
        }

        void Event2(){
            Console.WriteLine ("e2 is start");
            int i = 1;
            while (i < 1000) {
                i++;
                Console.WriteLine (i.ToString());
            }
            Console.WriteLine ("e2 is end");
        }

    }
}

 

async

原文:http://www.cnblogs.com/nnnnn/p/4524872.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!