1
I need an application to run in the background, in the system tray, 3 times a day, at 08:00, 12:00 and 16:00 it runs a file. exe.
1
I need an application to run in the background, in the system tray, 3 times a day, at 08:00, 12:00 and 16:00 it runs a file. exe.
1
You can use the Quartz library Enterprise Scheduler . NET to perform scheduled tasks in an application, either at a preset time or from time to time.
Quartz.NET is a full-featured, open source job Scheduling system that can be used from smallest apps to large Scale Enterprise systems.
It is a Pure . NET library Written in C# and is a port of very popular open source Java job Scheduling framework, Quartz.
0
I like to use the Fluentscheduler , as its name suggests, it has a fluent writing.
With it you can write something like this :
using FluentScheduler;
public class MeuAgendamento : Registry
{
public MeuAgendamento()
{
Schedule(() => Console.WriteLine("Vou executar todos os dias às 08:00 ")).ToRunEvery(1).Days().At(8, 0);
Schedule(() => Console.WriteLine("Vou executar todos os dias às 12:00 ")).ToRunEvery(1).Days().At(12, 0);
Schedule(() => Console.WriteLine("Vou executar todos os dias às 16:00 ")).ToRunEvery(1).Days().At(16, 0);
Schedule(() => Console.WriteLine("E se quiser posso executar a cada 3 meses, na primeira sexta-feira às 11:47 ")).ToRunEvery(3).Months().OnTheFirst(DayOfWeek.Friday).At(11, 47);
Schedule(() => MeuMetodo()).ToRunNow().AndEvery(4).Hours();
}
private void MeuMetodo()
{
Console.WriteLine("Ou executar um método agora e então cada 4 horas");
}
}
//Depois basta inicializar os agendamentos.
//Se for um serviço do windows essa inicialização pode ser no OnStart do serviço.
//Se for um webSite, essa inicialização pode ocorrer no Application_Start.
class static Main (string[] args)
{
TaskManager.Initialize(new MeuAgendamento());
}
You can download it by Nuget.
Browser other questions tagged c#
You are not signed in. Login or sign up in order to post.
You already have some code ready to ask the question?
– Leonel Sanches da Silva
You have two basic paths, schedule this on the operating system or leave the application running (if possible as a service to "secure" its execution is to put a Timer on it. http://answall.com/q/30601/101 It seems to me that what you want is to create an application that schedules the execution of another application. If so, it doesn’t make much sense. It’s best to schedule in the OS the application you should run at regular times. If it’s something else, explain it better.
– Maniero
If it is in Windows, the task scheduler serves exactly that. It was developed and evolved for years leading a number of OS issues, probably the most suitable tool. Under linux, crontab is the most suitable path.
– Bacco