admin 管理员组文章数量: 1184232
我们知道 core支持console和web开发,分别叫做 core程序和asp core.
查询 core官方文档,并没有介绍编写windows service相关的说明,一直以来以为dotnet core不支持windows service开发,知道查看asp core部署文档中提到可以部署在Windows service中,从而确定dotnet是可以开发Windows service的.
查看asp core的Windows宿主的源代码Microsoft.AspNetCore.Hosting.WindowsServices,发现最终给宿主是继承自System.ServiceProcess.ServiceBase,同时实现了OnStart以及OnStop等一些列方法.我们知道dotnet framework 中的service基类也是System.ServiceProcess.ServiceBase,所以可以试下按照传统的dotnet framework的方法尝试开发Windowsservice.
我们新建一个dotnet console程序,添加一个windows服务,取名WinService
默认代码如下:
using System;
using System.Collections.Generic;
using System.
版权声明:本文标题:.net core开发Windows服务 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/b/1766069162a3434135.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论