window 服务
1:windows 服务地址:
http://www.cnblogs.com/hfliyi/archive/2012/08/12/2635290.html
2: windows 服务下篇:
http://www.cnblogs.com/hfliyi/archive/2012/08/12/2635396.html
3:windows 服务Csdn地址:
http://blog.csdn.net/sophiazhou/article/details/7241150
4:
protected override void OnStart(string[] args) { string state = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "启动"; WriteLog(state); var timer = new System.Timers.Timer(3000); timer.AutoReset = true; timer.Elapsed += new System.Timers.ElapsedEventHandler(OnEventTime); timer.Enabled = true; } private void OnEventTime(object sender, System.Timers.ElapsedEventArgs e) { string state = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "执行中..."; WriteLog(state); } private void WriteLog(string str) { using (StreamWriter sw = File.AppendText(@"D:\ServicesLog.txt")) { sw.WriteLine(str); sw.Flush(); } } protected override void OnStop() { // TODO: 在此处添加代码以执行停止服务所需的关闭操作。 string state = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "停止"; WriteLog(state); }