Windows 2003 服务和计时器问题导致 Tick 不被调用?

发布于 2024-07-29 08:25:30 字数 636 浏览 2 评论 0原文

Win2k3 上的服务中的计时器存在一些问题... 基本上,创建一个服务,每 X 分钟/秒检查某个进程及其是否正在运行。 我认为完成此任务的最简单方法是通过计时器。

已成功安装该服务,并且似乎报告其启动/停止正常。 我已使用 Eventlog.WriteEntry 写入事件日志,并观察到它正在到达启动功能,但没有到达计时器滴答声。

            EventLog.WriteEntry("SETTINGS SET");
            // Set our timer's interval to the value set in the settings.xml file.
            tmrCheck.Interval = Int32.Parse(_settingChkInterval) * 1000;
            // Enable our timer and away we go, checking away!
            tmrCheck.Enabled = true;
            // Set our Tick event to our Tick void
            tmrCheck.Tick += new EventHandler(tmrCheck_Tick_1);

Having a few problems with Timers within a service on Win2k3...
Basically, creating a service that every X minutes/seconds, checks for a certain process and whether it is running. I figured the easiest way to get this done was via a Timer.

Have managed to install the service fine, and it seems to be reporting that it is starting/stopping OK. I have written to the eventlog using Eventlog.WriteEntry, and have observed that it is reaching the startup function, but not the Timer Tick.

            EventLog.WriteEntry("SETTINGS SET");
            // Set our timer's interval to the value set in the settings.xml file.
            tmrCheck.Interval = Int32.Parse(_settingChkInterval) * 1000;
            // Enable our timer and away we go, checking away!
            tmrCheck.Enabled = true;
            // Set our Tick event to our Tick void
            tmrCheck.Tick += new EventHandler(tmrCheck_Tick_1);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无名指的心愿 2024-08-05 08:25:30

嗯,您不能在服务中使用 Winform 计时器。

您需要使用 System.Timers.Timer 或 System.Threading.Timer。

Mmmm, you cant use a Winform timer in a service.

You need to use System.Timers.Timer or System.Threading.Timer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文