/// <summary> /// 计时,并用控制台输出行 /// </summary> /// <param name="title"></param> /// <param name="times"></param> /// <param name="action"></param> public static void TimeLine(String title, Int32 times, Action<Int32> action) { Console.Write("{0,16}:", title); DME_CodeTimer timer = new DME_CodeTimer(); timer.Times = times; timer.Action = action; timer.ShowProgress = true; ConsoleColor currentForeColor = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Yellow; timer.TimeOne(); timer.Time(); Console.WriteLine(timer.ToString()); Console.ForegroundColor = currentForeColor; }
/// <summary> /// 计时 /// </summary> /// <param name="times"></param> /// <param name="action"></param> /// <returns></returns> public static DME_CodeTimer Time(Int32 times, Action<Int32> action) { DME_CodeTimer timer = new DME_CodeTimer(); timer.Times = times; timer.Action = action; timer.TimeOne(); timer.Time(); return timer; }