10 分钟后,文件观察程序在 c# 中启动

本文关键字:启动 程序 观察 分钟 文件 | 更新日期: 2023-09-27 18:33:14

我渴望在 c# 中使用文件观察器并将所有操作保存在数据库中,但我希望每隔 10 分钟文件观察器启动并将记录插入 databse 所以我怎么做?

10 分钟后,文件观察程序在 c# 中启动

您可以使用调度程序每 10 分钟执行一次代码例

DispatcherTimer dispatcherTimer = new DispatcherTimer();
dispatcherTimer.Interval = new TimeSpan(0, 10, 0);
dispatcherTimer.Tick += timer_Tick;
private void timer_Tick(object sender, EventArgs e)
{
           //your save db code
}

为 DispatcherTimer 添加 System.Windows.Threading dll 的引用