创建需要计时器的windows service
1、在VS中建立windows service后,应该添加一个安装程序。
2、在默认的Service1.cs设计界面右键,添加安装程序,生成ProjectInstaller。包含两个类serviceProcessInstaller和serviceInstaller。
3、前者的属性Account一般应设为LocalSystem。
4、如需要计时器,不应使用winform的计时器,而是System.Timers.Timer。
于是在Service1.cs中
添加私有变量:
private System.Timers.Timer timer;
然后在初始化时:
private void InitializeComponent()
{
this.timer = new System.Timers.Timer();
((System.ComponentModel.ISupportInitialize)(this.timer)).BeginInit();
//
// timer
//
this.timer.Enabled = true;
this.timer.Interval = 120000D; //循环时间,单位毫秒
this.timer.Elapsed += new System.Timers.ElapsedEventHandler(this.aTimer_Elapsed);
//
// iLearningPush
//
this.ServiceName = "myService";
((System.ComponentModel.ISupportInitialize)(this.timer)).EndInit(); }
5、Service1的属性ServiceName为部署后的服务名称
6、windows服务需要InstallUtil工具来安装。
创建需要计时器的windows service的更多相关文章
- .NET 6学习笔记(2)——通过Worker Service创建Windows Service
通过Visual Studio中的Windows Service模板,我么可以创建.NET Framework版本的Windows Service,网络上对此已有详细且丰富的各路教程.但在我们升级到. ...
- 创建Windows Service
基本参照使用C#创建Windows服务,添加了部分内容 目录 创建Windows Service 可视化管理Windows Service 调试 示例代码 创建Windows Service 选择C# ...
- C#创建、安装、卸载、调试Windows Service(Windows 服务)的简单教程
前言:Microsoft Windows 服务能够创建在它们自己的 Windows 会话中可长时间运行的可执行应用程序.这些服务可以在计算机启动时自动启动,可以暂停和重新启动而且不显示任何用户界面.这 ...
- windows Service 创建部署
Windows Service简介: 一个Windows服务程序是在Windows操作系统下能完成特定功能的可执行的应用程序.Windows服务程序虽然是可执行的,但是它不像一般的可执行文件通过双击就 ...
- C# 创建Windows Service
当我们需要一个程序长期运行,但是不需要界面显示时可以考虑使用Windows Service来实现.这篇博客将简单介绍一下如何创建一个Windows Service,安装/卸载Windows Servi ...
- C#创建Windows Service(Windows 服务)基础教程
Windows Service这一块并不复杂,但是注意事项太多了,网上资料也很凌乱,偶尔自己写也会丢三落四的.所以本文也就产生了,本文不会写复杂的东西,完全以基础应用的需求来写,所以不会对Window ...
- C# Windows Service服务的创建和调试
前言 关于Windows服务创建和调试的文章在网络上的很多文章里面都有,直接拿过来贴在这里也不过仅仅是个记录,不会让人加深印象.所以本着能够更深刻了解服务项目的创建和调试过程及方法的目的,有了这篇记录 ...
- windows service创建使用整合
C#创建Windows Service(Windows 服务)基础教程 C#winform windows服务程序创建与安装 C#实现WinForm随WINDOWS服务一起启动
- C#Windows Service程序的创建安装与卸载
C#Windows Service程序的创建安装与卸载 一.开发环境 操作系统:Windows7x64 sp1 专业版 开发环境:Visual studio 2013 编程语言:C# .NET版本: ...
随机推荐
- 【翻译四】java-并发之线程暂停
Pausing Execution with Sleep Thread.sleep causes the current thread to suspend execution for a speci ...
- 【JAVA Properties类概述】
一.概述. 之前说过,该对象是和IO流相结合的技术,所以和IO流结合在一起来讲比较合适. public class Propertiesextends Hashtable<Object,Obje ...
- 动态生成SQL执行语句
SET @qry = 'SELECT product_cd, name, product_type_cd, date_offered, date_retired FROM product WHERE ...
- SQLAlchemy Core插入数据,有好几种方法呢
看是一次插入一条还是多条, 看是数据表名是变量还是常量, 操作还是很灵活的, 主要看哪种顺手顺眼啦. #coding=utf-8 from datetime import datetime from ...
- 2016"百度之星" - 初赛(Astar Round2A)Gym Class(拓扑排序)
Gym Class Accepts: 849 Submissions: 4247 Time Limit: 6000/1000 MS (Java/Others) Memory Limit: 65 ...
- [Maven] Missing artifact (解决办法)
在使用Eclipse的Maven插件时,经常会遇到Missing artifact的编译错误,特别是在新环境中搭建相关项目时,经常出现类似此问题,今天一位同事又遇到了,经过一顿问题原因查找,始终无法解 ...
- Tips for OpenMesh
OpenMesh 求两点之间的距离 MyMesh::Point p1(1,2,3); MyMesh::Point p2(1,2,5); double d=(p1-p2).length();
- 直接拿来用!最火的Android开源项目(二)(转)
GitHub上的开源项目不胜枚举,通过这些项目,也能让开发者在应用开发过程中事半功倍,作为开发者的你,在用这些开源项目吗?今天我们将介绍另外20个在GitHub上备受欢迎的Android开源项目,你准 ...
- Android之Adapter用法总结(转)
Android之Adapter用法总结 1.概念 Adapter是连接后端数据和前端显示的适配器接口,是数据和UI(View)之间一个重要的纽带.在常见的View(List View,Grid Vie ...
- 查询sqlserver 正在执行的sql语句的详细信息
SELECT [Spid] = session_Id, ecid, [Database] = DB_NAME(sp.dbid), [User] = nt_username, [Status] = er ...