I want to create one fabric service which runs at a specific time irrespective of its execution time.
I have created a fabric service with actor reminders and set a period to run every 3 minutes. In the call-back function, I have put a delay of 2 minutes as function processing time.
My code looks like below
public async Task ReceiveReminderAsync(string reminderName, byte[] state, TimeSpan dueTime, TimeSpan period)
{
var current = DateTime.Now;
if (reminderName.Equals("TaskReminder"))
{
Thread.Sleep(2 * 60 * 1000);
using (var writer = File.AppendText("actor.txt"))
{
await writer.WriteLineAsync("1 :: " + current.ToString() + " --> " + DateTime.Now.ToString());
}
}
}
protected override async Task OnActivateAsync()
{
await RegisterReminderAsync("TaskReminder", null, TimeSpan.FromSeconds(10), TimeSpan.FromMinutes(3));
}
And my logs in Actor.txt looks like below
1 :: 12/28/2021 4:54:52 PM --> 12/28/2021 4:56:52 PM
1 :: 12/28/2021 4:59:52 PM --> 12/28/2021 5:01:52 PM
1 :: 12/28/2021 5:05:52 PM --> 12/28/2021 5:07:52 PM
I want it to run every 3 minutes but it's adding function execution time(2 minutes) and running at every 5 minutes instead.