How to schedule a service to run daily and at specific time using service fabric?

275 Views Asked by At

I am trying to build a service in such away that it runs once a day at a specific time to minimize multiple calls to the database using service fabric

1

There are 1 best solutions below

2
Preben Huybrechts On

You can use Actor reminders

You need to call RegisterReminderAsync. To run every 24 hours


var reminderRegistration = await this.RegisterReminderAsync(
        reminderName,
        BitConverter.GetBytes(amountInDollars),
        TimeSpan.FromMinutes(0),    //The amount of time to delay before firing the reminder
        TimeSpan.FromHours(24));    //The time interval between firing of reminders

If you want to run at a specific time, you can trigger every hour/ x minutes and in the method you can check if DateTime.UtcNow is in the correct window.