日期:2014-05-18 浏览次数:21105 次
public class DoActions { public void Doing(int i) { Thread.Sleep(4000); Console.WriteLine(i.ToString()); } } static void Main(string[] args) { for (int i = 0; i < 10; i++) { //create a Job object DoActions objJob = new DoActions(); Action action = new Action(delegate() { objJob.Doing(i); }); action.BeginInvoke(null, null); } Console.WriteLine("Loop over."); Console.ReadKey(); return; }