private bool isrun;
protected override void OnStart(string[] args)
{
isrun =true;
while (isrun)
{
try
{
StreamWriter sw = File.AppendText(@"d:\myserver.txt");
sw.WriteLine(string.Format("服务启动,启动时间{0}", DateTime.Now));
}
}
catch (Exception ex)
{
WirteWinLog(ex);
}
System.Threading.Thread.Sleep(10*1000);
}
}
protected override void OnStop()
{
isrun=false;
StreamWriter sw = File.AppendText(@"d:\myserver.txt");
sw.WriteLine(string.Format("服务停止,启动时间{0}", DateTime.Now));
sw.Close();
}
为什么服务发布后无法停止呢????
慕森卡
潇潇雨雨