我的Windows服务突然不工作,并开始促使错误1053错误1053:该服务没有启动或控制请求及时
这是我下面的程序在C#
using System;
using System.Net;
using System.IO;
using System.Data;
using System.ComponentModel;
using System.Collections.Generic;
using System.Collections;
using System.Text;
using System.ServiceProcess;
using System.Runtime.InteropServices;
using System.Diagnostics;
using EPocalipse.IFilter;
using System.Timers;
using System.Threading;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Net.Mail;
using System.Xml;
namespace MyWindowsService
{
class Program : ServiceBase
{
System.Timers.Timer timer = new System.Timers.Timer();
public static void Main(string[] args)
{
// If we are in debug mode, start it as a console app
#if DEBUG
Program instance = new Program();
instance.OnStart(null);
//Console.ReadLine();
instance.OnStop();
// If we are NOT in debug mode, start it as a service
#else
ServiceBase.Run(new Program());
#endif
}
public Program()
{
CanPauseAndContinue = false;
this.ServiceName = "MySciente Service 2012";
}
protected override void OnStart(string[] args)
{
base.OnStart(args);
//System.Threading.Thread.Sleep(20 * 60 * 1000);
startMyService();
}
protected override void OnStop()
{
base.OnStop();
timer.Enabled = false;
//sendMail();
}
private void InitializeComponent()
{
}
private void startMyService()
{
fileMigration();
timer.Elapsed += new ElapsedEventHandler(OnElapsedTime);
timer.Interval = (15 * 60 * 1000); //15 is minutes, so here is 15 minutes
timer.Enabled = true;
}
private void OnElapsedTime(object source, ElapsedEventArgs e)
{
fileMigration();
}
public static void fileMigration()
{
--My Program--
}
}
}
我可以知道它是什么原因造成的?之后windows &反病毒更新我的服务从上个月引起这个问题15th
发生此错误时, onstart方法需要很长的时间来终止,我建议你看看事件查看器的更多信息 – mfarouk 2014-10-03 08:48:04