日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

beginInvke帶回調函數使用

作者:彭先生zzZ 更新時間: 2022-08-13 編程語言
 static void Main(string[] args)
        {

            //AsnycRes_Dog dog = new AsnycRes_Dog();
            //var man = new Man(dog);
            //var thief = new Thief(dog);

            //dog.HappenEvent();
            //Console.ReadKey();


            //異步阻塞 通過endinvoke
            
            BeginInvoeUserTest be = new BeginInvoeUserTest();
            Program p = new Program();
            be.mutiDel = be.WaysToMuti;
            var Ways = be.mutiDel;
            IAsyncResult Result = Ways.BeginInvoke(10, 20, p.CWWAYS, null);
            while (!Result.IsCompleted)
            {
                Console.WriteLine("Runing .........");
                Thread.Sleep(500);
            }
            int Res = Ways.EndInvoke(Result);

            Console.WriteLine(Res);

            Console.ReadKey();

        }


        public void CWWAYS(IAsyncResult ir)
        {
            Console.WriteLine("計算完成了!!!");
        }
class BeginInvoeUserTest
    {
        public delegate int MutiNum(int a, int b);
        public MutiNum mutiDel;
        public int WaysToMuti(int a, int b)
        {
            int Result = a+b;
            for (int i = 0; i < 10; i++)
            {
                Thread.Sleep(500);
                Result += a;
            }
            return Result;
        }


    }

原文鏈接:https://blog.csdn.net/weixin_44035651/article/details/126307710

欄目分類
最近更新