一 开发:

1、新建控制台程序

2、nuget下载topshelf,根据不同的net版本选择下载版本,本人4.5下载3.3.1

3、main方法中增加

HostFactory.Run(x =>
{
x.Service<Rabbit>(s =>
{
s.ConstructUsing(name => new Rabbit());//Rabbit是下面具体的业务类,实现具体业务
s.WhenStarted(ra => ra.Start());//Start() Rabbit类方法
s.WhenStopped(ra => ra.Stop());//Stop() Rabbit类方法
}); //x.RunAsLocalSystem();
x.RunAsLocalSystem();
x.SetDescription("订单完成升级为网店"); //服务管理器中服务选项卡中描述栏显示的内容
x.SetDisplayName("OrderCompleteUpgradeToShop");//任务管理器中服务选项卡名称栏显示内容
x.SetServiceName("OrderCompleteUpgradeToShop");//服务管理器中显示名称
x.StartAutomatically();//自动启动,启动模式 });
public class Rabbit
{ public void Start()
{
//实现 } public void Stop()
{
//实现
}
}

二 安装服务:

安装
rabbitWinServer.exe install
启动
rabbitWinServer.exe start
停止
rabbitWinServer.exe stop
卸载
rabbitWinServer.exe uninstall

生成项目后可以在debug文件夹找到生成的文件,shift+鼠标右键弹出“在此处打开命令窗口”,运行上面的相应代码

Note:其中rabbitWinServer.exe为exe的名称

三 查看服务安装及运行结果:

完成

相关图示:

topshelf windows服务的更多相关文章

  1. Quartz和TopShelf Windows服务作业调度

    上一次写了一遍关于Quartz作业调度的文章 Quartz.NET 作业调度使用 现在使用TopShelf和Quartz实现windows服务作业调度 TopShelf版本4.0 Quartz版本3. ...

  2. 使用topshelf包装redis为windows服务

           Redis服务端目前用的是控制台程序运行,部署的时候能作为windows服务后台运行感觉更好.找到一篇文章Running Redis as a Windows Service,利用win ...

  3. topshelf包装redis为windows服务

    topshelf包装redis为windows服务 Redis服务端目前用的是控制台程序运行,部署的时候能作为windows服务后台运行感觉更好.找到一篇文章Running Redis as a Wi ...

  4. 使用Topshelf创建Windows服务

    概述 Topshelf是创建Windows服务的另一种方法,老外的一篇文章Create a .NET Windows Service in 5 steps with Topshelf通过5个步骤详细的 ...

  5. 使用Topshelf 开发windows服务

    在业务系统中,我们为了调度一些自动执行的任务或从队列中消费一些消息,所以基本上都会涉及到后台服务的开发.如果用windows service开发,非常不爽的一件事就是:调试相对麻烦,而且你还需要了解 ...

  6. [Solution] Microsoft Windows 服务(2) 使用Topshelf创建Windows服务

    除了通过.net提供的windows服务模板外,Topshelf是创建Windows服务的另一种方法. 官网教程:http://docs.topshelf-project.com/en/latest/ ...

  7. 使用Topshelf 5步创建Windows 服务 z

    使用Topshelf创建Windows 服务简要的介绍了创建Windows服务的另一种方法,老外的一篇文章Create a .NET Windows Service in 5 steps with T ...

  8. 使用Topshelf创建Windows 服务

    本文转载: http://www.cnblogs.com/aierong/archive/2012/05/28/2521409.html http://www.cnblogs.com/jys509/p ...

  9. Topshelf创建Windows服务

    使用Topshelf创建Windows服务 概述 Topshelf是创建Windows服务的另一种方法,老外的一篇文章Create a .NET Windows Service in 5 steps ...

随机推荐

  1. PC站与H5移动站最佳适配方案

    HTML5是目前HTML的最屌版本,同时也是建设移动站的最佳技术.百度适时推出PC站与H5移动站的最佳适配方案,对站长而言实在是久旱逢甘霖.详情如下: PC站与H5移动站最佳适配方案 pc端: 在pc ...

  2. SpringBoot application.properties 配置项详解

    参考: http://blog.csdn.net/lpfsuperman/article/details/78287265### # spring boot application.propertie ...

  3. JDBC记录

    13:55 2018/7/22 用于执行SQL语句的Java API,可以为多种关系数据库提供统一访问 ---------常用API--------- |- Driver接口: 表示java驱动程序接 ...

  4. Feel Good(两遍单调栈维护区间+前缀和)

    Bill is developing a new mathematical theory for human emotions. His recent investigations are dedic ...

  5. vbs SendKeys技术 vbs SendKeys

    简单说,这个命令就是模拟键盘操作,将一个或多个按键指令发送到指定Windows窗口来控制应用程序运行,其使用格式为:object.SendKeys string"object":表 ...

  6. [源代码]List的增加与删除

    // Removes the element at the given index. The size of the list is // decreased by one. // public vo ...

  7. ubuntu中安装kernel-devel

    kernel-devel is a RedHat and derivatives package. In Ubuntu you may need to install the linux-kernel ...

  8. tomcat普通用户启动不了

    Neither the JAVA_HOME nor the JRE_HOME environment variable is defined  At least one of these enviro ...

  9. DOC窗口之cd命令(windows)

    cd的全称是Change Directory,改变文件夹,也就是切换路径.后面可以接驱动器符号.完整路径和相对路径. 通常win+R,输入cmd,便会看到以下界面, 通常,这个命令下并没有我们想要处理 ...

  10. ESC/POS 控制指令

    ESC/POS  控制指令 HT 横向跳格 [名称] Horizontal tab [格式] ASCII HT Hex 09 Decimal 9 [描述] 将当前位置移动到下一个跳格位置. [注释] ...