[英]Can I use BackgroundService in dot net core console application
I know how to use background service in asp.net core我知道如何在asp.net core中使用后台服务
public class WatchMan : BackgroundService
{
}
I have a dot core console application which I want to run as window service, can I use BackgroundService
or something similar there?我有一个 dot core 控制台应用程序,我想将它作为窗口服务运行,我可以在那里使用BackgroundService
或类似的东西吗?
Yes, just be sure to keep the main thread alive so the application does not exit.是的,只要确保主线程保持活动状态,应用程序就不会退出。
This article seems to explain the process decently;这篇文章似乎很好地解释了这个过程; https://medium.com/@daniel.sagita/backgroundservice-for-a-long-running-work-3debe8f8d25b https://medium.com/@daniel.sagita/backgroundservice-for-a-long-running-work-3debe8f8d25b
And here's an SO that shows the process aswell:这是一个显示该过程的 SO:
Trigger background service ExecuteAsync method in .Net core console application 在.Net核心控制台应用程序中触发后台服务ExecuteAsync方法
Also if you want to do some background processing, take a look at hangfire:另外如果你想做一些后台处理,看看hangfire:
https://www.hangfire.io/ https://www.hangfire.io/
Which can also be ran from a windows service.也可以从 Windows 服务运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.