C# 每分整秒運行
using System.Dynamic; namespace CycleSeco { internal class Program { static void Main(string[] args) { setTaskAtFixedTime(); while (true) { Console.WriteLine($"{DateTime.Now}"); System.Threading.Thread.Sleep(1000); } } static DateTime LastTime; private static void setTaskAtFixedTime() { DateTime now = DateTime.Now; var WaitMinSeco = now.Subtract(LastTime).TotalMilliseconds; if (WaitMinSeco < 1000) { Console.WriteLine($"Wait {1000 - Convert.ToInt32(WaitMinSeco)} MinSeco"); System.Threading.Thread.Sleep(1000 - Convert.ToInt32(WaitMinSeco)); } int[] SetSeco = new int[] { 0, 10, 20, 30, 40, 50 }; DateTime NextTime = DateTime.Now; var bb = SetSeco.Select(x => now.AddSeconds(-now.Second).AddSeconds(x)).Wher