码迷,mamicode.com
首页 > 其他好文 > 详细

async

时间:2015-05-23 21:23:05      阅读:158      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!