如何使用服务结构安排服务在每天和特定时间运行? [英] How to schedule a service to run daily and at specific time using service fabric?

查看:17
本文介绍了如何使用服务结构安排服务在每天和特定时间运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试构建一个服务,使其在特定时间每天运行一次,以最大限度地减少使用服务结构对数据库的多次调用

推荐答案

您可以使用Actor reminders

您需要调用RegisterRminderAsync。每24小时运行一次


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

如果要在特定时间运行,可以每小时/x分钟触发一次,并在该方法中检查DateTime.UtcNow是否在正确的窗口中。

这篇关于如何使用服务结构安排服务在每天和特定时间运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆