如何在asp.net中进行同步通知

How to make synchronous notification in asp.net

我在我的 Web 应用程序中使用 asp.net 中的 Web 表单,我需要进行后台处理以检查我的 SQL 数据库中是否每 10 分钟插入一次新记录并提供给我一个通知,我该怎么做...请帮忙。

在global.asaxApplication_Start中启动一个定时器。当计时器触发时,使用 HostingEnvironment.QueueBackgroundWorkItem 调用一个函数,该函数通过 SignalR

执行数据库查询和通知
void Application_Start(object sender, EventArgs e)
{
    var backgroundTimerTenMinutes = new System.Timers.Timer(600000);
    backgroundTimerTenMinutes.Elapsed += backgroundTimerTenMinutes_Elapsed;
}

void backgroundTimerTenMinutes_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
    HostingEnvironment.QueueBackgroundWorkItem(ct => DBQueryAndNotify(ct));
}