Example #1
0
 /// <summary>同步
 /// </summary>
 /// <param name="age"></param>
 public static void tb(int age)
 {
     Func<string> Func = new Func<string>(() =>
     {
         people tPeo = new people("同步小李", age);
         return tPeo.ToString();
     });
     //同步执行,获取返回结果
     Console.WriteLine(Func.Invoke());
 }
Example #2
0
 /// <summary>异步
 /// </summary>
 /// <param name="age"></param>
 public static void yb(int age)
 {
     //异步执行
     Func<string> FuncAsy = new Func<string>(() =>
     {
         people tPeo = new people("异步小李", age);
         return tPeo.ToString();
     }
     );
     FuncAsy.BeginInvoke(resual =>
     {
         //异步执行,从回调函数中获取返回结果
         Console.WriteLine(">>>>:{0}", FuncAsy.EndInvoke(resual));
         Console.WriteLine(">>>>:{0} end", age);
     }, null);
 }