using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace 委托多线程 { classProgram { publicdelegate void Anydelegate(inti);//定义委托 staticvoid Main(string[]args) { ClassAm = new ClassA(); Anydelegatem1 = new Anydelegate(m.s); for(int i = 0; i < 50; i++) { m1.BeginInvoke(i, null, null); } Console.ReadKey(); } } publicclass ClassA { publicvoid s(int i) { System.Threading.Thread.Sleep(100); Console.WriteLine("这是第{0},当前的线程是{1}", i, System.Threading.Thread.CurrentThread.ManagedThreadId); } } }
委托多线程
最新推荐文章于 2023-07-02 18:20:35 发布