您的位置:首页 > 其它

创建window service --菜鸟篇

2009-03-27 15:50 134 查看
1.打开vs---->新建windows服务

2.设置属性

CanPauseAndContinue:是否可以暂停与继续

CanStop ;是否可以停止

3.在工具栏里拖timer空间到设计器(注:system.timers.timer ,如果没有点击“选择项”添加)

4.设置timer 属性

Enabled:启用定时

Interval:运行间隔(毫秒)

5.添加代码

onStart():这里是服务启动时运行的代码

onStop():这里是服务停止时运行的代码

timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)在这里添加要定时运行的代码

6.添加安装程序

右键点击设计器--->添加安装程序

account:localSystem

startType:auotmatic

7.注册服务

installutil.exe 你的服务所在目录
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: