C# 轮循回调
class Program { static void Main(string[] args) { Func<int> func = new Func<int>(GetInt); var iar = func.BeginInvoke(new AsyncCallback(Show), null); while (!iar.IsCompleted) { Thread.Sleep(1000); Console.WriteLine("收到了您的提示!"); } Console.WriteLine("处理结果为{0}!",func.EndInvoke(iar)); Console.ReadKey(); } private static void Show(IAsyncResult iar) { while (iar.IsCompleted) { Console.WriteLine("执行完毕!"); break; } } private static int GetInt() { for (var i = 0; i < 10; i++) { Console.WriteLine("请稍等,我正在执行,需要点时间"); Thread.Sleep(1000); } return 1; } }
欢迎加入群:254082423
一起学习讨论asp.net mvc