学无先后,达者为师

网站首页 编程语言 正文

beginInvoke加回调函数lamad

作者:彭先生zzZ 更新时间: 2022-08-13 编程语言
class Program
    {
        public delegate void MyFunction(string msg);

        public static void Main(string[] args)
        {
            MyFunction fn = StartA;
            fn.BeginInvoke("【B】要开始运行了!", asyncCallback=> {
                for (int i = 1; i <= 1000; i++)
                {
                    Console.WriteLine("\t\t\t【B】运行了" + i + "‰");
                };
            },null);

            Console.WriteLine("【A】要开始运行了!");
            for (int i = 1; i <= 1000; i++)
            {
                Console.WriteLine("\t【A】运行了" + i + "‰");
            };

            Console.ReadKey();
        }


        public static void StartA(string msg)
        {
            Console.WriteLine(msg);
        }
    }

原文链接:https://blog.csdn.net/weixin_44035651/article/details/126308049

栏目分类
最近更新