Make MyFunction() trigger every minute
问题 I have this C# code and I want it to trigger every minute. private void MyFunction() { if (DateTime.Now.Hour == 6 && ranalarm == false) { ranalarm = true; Event(); } else if (DateTime.Now.Hour != 6 && ranalarm == true) { ranalarm = false; } } How can I make function MyFunction() trigger every minute in C#? I tried working with timers but Visual Studio said it conflicted with my System.Windows.Forms . 回答1: You can use System.Threading.Timer and TimeSpan. Something like this: TimeSpan start =