C# Execute function at specific time

后端 未结 6 954
暖寄归人
暖寄归人 2020-12-06 03:06

I made a little Windows Forms program to do some auto backup of some files on my disk. Right now I need to push a button before it is executed, but I want to make the progra

6条回答
  •  一向
    一向 (楼主)
    2020-12-06 03:56

    One option is to use a timer. This requires that your program keep running.

    If you want to use a timer then set it to fire (every second, for example)

    myTimer.Interval = 1000;
    

    In the delegate function that's called, compare the current time with your target time and if they match, launch your backup process.

提交回复
热议问题