码迷,mamicode.com
首页 > Windows程序 > 详细

window service 创建

时间:2015-09-02 20:44:07      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:

1:vs中创建一个 window servece 

2.右键 添加安装程序

3.更改属性视图中的Account属性为LocalService(本地服务) 更改ServiceName为你自己的服务名称   StartType默认为手动,可以更改为自动

 

创建一个定时器

Timer aTimer = new Timer();
aTimer.Interval = 3000 * 1000;
aTimer.Elapsed += new ElapsedEventHandler(TimedEvent);
aTimer.Enabled = true;

/// <summary>
/// 开始周期执行函数 -- 
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
private void TimedEvent(object source, ElapsedEventArgs e)
{
  Action();
}

4.添加到服务中: 找到 菜单-》所有程序-》Visual Studio 2013->Visual Studio Tools ->VS2013 开发人员命令提示 

进入安装程序的目录,输入:installutil LifePower.exe  就可以安装了。

卸载进入目录:installutil  /u  LifePower.exe 即卸载

 

window service 创建

标签:

原文地址:http://www.cnblogs.com/90nice/p/4779284.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!