Planning Timers in C #

After starting my application, I want to start my application sometimes later, and not immediately after launching it. How to do it? May I take the time when I want to launch my application through the comand.Please help.Thanx line in advance.

Regards, Sanchaita Sujit Chakraborty

+3
source share
3 answers

I don’t understand exactly what you want to achieve, but Quartz.NET is a library that you can use to schedule tasks in .NET ..

+3
source

schtasks: System.Diagnostics.Process.Start("schtasks", @"/create /tn mytask /tr C:\mypgm.exe /sc daily /st 18:55:00"); schtasks , .

+2

you can use the System.Threading.Timer class to schedule a method call

static void Main(string [] args)
{
    DateTime? startDate = null;
    if(args.length>1) 
    {
        DateTime.TryParse(args[0], out startDate);
    }
    if(startDate.HasValue && DateTime.Now<startDate.Value)
    {
        System.Threading.Timer timer = new System.Threading.Timer(new TimerCallback(StartProgram));
        timer.Change(startDate.Value.Substract(DateTime.Now).TotalMilliseconds, Timeout.Infinite);
    }
    else
        StartProgram();
}
private static void StartProgram()
{
    Console.WriteLine("Started");
    //rest of you code
}
0
source

Source: https://habr.com/ru/post/1793224/


All Articles