C# Execute function at specific time

后端 未结 6 952
暖寄归人
暖寄归人 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:52

    You can use: System.Forms.Timer

    If you don't know the amount of time until you want to Execute do something like:

    DateTime TimeToExecuteTask
    DateTime Now = DateTime.Now // assign values.
    
    int SecondsToExectution = (TimeSpan)(TimeToExecuteTask - Now).TotalSeconds;
    

提交回复
热议问题