using System.ServiceProcess;
using System.Timers;
using System.Windows.Forms;
namespace MyAlertWindowsService
{
public partial class MyFirstAlertWindowsService : ServiceBase
{
private System.Timers.Timer timer;
public MyFirstAlertWindowsService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
timer = new System.Timers.Timer();
timer.Interval = 60000; // 1分钟
timer.Elapsed += new ElapsedEventHandler(OnTimerElapsed);
timer.Enabled = true;
}
private void OnTimerElapsed(object sender, ElapsedEventArgs e)
{
MessageBox.Show("这是一个定时弹窗!");
}
protected override void OnStop()
{
timer.Enabled = false;
timer.Dispose();
}
}
}
C:WindowsMicrosoft.NETFramework64v4.0.30319
installutil.exe D:mmvs2022MyAlertWindowsServicebinDebugMyAlertWindowsService.exe
installutil.exe /uninstall D:mmvs2022MyAlertWindowsServicebinDebugMyAlertWindowsService.exe
原文地址:https://blog.csdn.net/qq_33881408/article/details/134690714
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_43178.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!