static void Main(string[] args) { Console.Title = "Snake 贪吃蛇! By:黄琨智"; SetWindowPositionCenter(); Console.CursorVisible = false; Start(); #region 定时垃圾清理 System.Timers.Timer gcT = new System.Timers.Timer(); gcT.Elapsed += GcT_Elapsed; gcT.Interval = 10000; gcT.Start(); #endregion #region 键委托执行 Thread keyThread = new Thread(() => { while (true) { ConsoleKey key = Console.ReadKey(true).Key; lock (keyLock) { keyDel.Invoke(key); } } }); keyThread.Start(); #endregion #region Update委托执行 while (true) { if (Environment.TickCount - runningTime > 5) { runningTime = Environment.TickCount; nowFrame += 1; lock (keyLock) { updateDel.Invoke(); } } } #endregion }