Windows进程,定时执行

install.bat
InstallUtil.exe


namespace MailService
{
public partial class Service1 : ServiceBase
{
private const string ERROR_MAIL_TITLE = "邮件发送失败";
private System.Timers.Timer mailTimer, mailTimer2, mailTimer3;
private static int i = 0, j = 0, k = 0;

public Service1()
{
InitializeComponent();
}

protected override void OnStart(string[] args)
{
try
{
//资产操作记录发送邮件,每20分钟执行一次 
//mailTimer = new Timer(1000*60*20);
//mailTimer.Elapsed += new System.Timers.ElapsedEventHandler(ScheduleSendMail);
//mailTimer.Enabled = true;
//mailTimer.AutoReset = true; 

Thread.CurrentThread.Join(1000 * 10);
SendMail_Stage();

}
catch (Exception ex)
{

}
}

protected override void OnStop()
{
}

private void ScheduleSendMail(object source, System.Timers.ElapsedEventArgs e)
{
SendMail_Stage(); 



private static void SendMail_Stage()




}

原文地址:https://www.cnblogs.com/cw_volcano/p/2108596.html