这段代码是无限循环的吗?

Pic*_*ght 4 c# timer

我有以下代码,这是否运行无限循环?
我试图每分钟安排一些事情,控制台应用程序应该持续运行,直到我关闭它.

class Program
{
  static int curMin;
  static int lastMinute = DateTime.Now.AddMinutes(-1).Minutes;

 static void Main(string[] args)
 {
   // Not sure about this line if it will run continuously every minute??
   System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(TimCallBack), null, 1000, 60000);

  Console.Read();
  timer.Dispose();
 }
   private static void TimCallBack(object o)
   {
      curMin = DateTime.Now.Minute;
      if (lastMinute < curMin)
      {
          // Do my work every minute
          lastMinute = curMin;
      }
    }

}
Run Code Online (Sandbox Code Playgroud)

Sky*_*ers 10

KISS - 或者您正在争夺 Rube Goldberg奖?;-)

static void Main(string[] args)
{
   while(true)
   {
     DoSomething();
     if(Console.KeyAvailable)
     {
        break;     
     }
     System.Threading.Thread.Sleep(60000);
   }
}
Run Code Online (Sandbox Code Playgroud)