使用Windows服务或控制台应用程序好吗? [英] Is it good to have windows service or console application?
本文介绍了使用Windows服务或控制台应用程序好吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的数据库中有一个任务表。我想从该表中读取数据并运行任务。是将其作为Windows服务还是作为控制台应用程序运行,哪个更好。将在其上运行该服务器的服务器将不会关闭
I have a tasks table in my db. I want to read data from this table and run tasks. Which one is better whether to have it as windows service or a console application running. The server on which this will be run will not be shutdown
推荐答案
您很可能希望使用Windows服务。
You most likely want to use a windows service.
好处:
- 您可以控制用户(以及与之相关的权限此用户帐户)启动进程
- 一个自动启动的进程意味着需要打开桌面(而不是用户登录)才能运行服务
- 可以定义一个失败策略(如果失败,则尝试重新启动n次运行特定程序)
- 可以定义一个依赖项(如果您依赖其他服务)
- 您可以将脚本包装在不可见的窗口中
- 您可以轻松地启动/停止/重新启动脚本(
net start< scriptname>
)
- You can control the user (and the rights associated with this user account) which starts the process
- An automatically started process means the desktop need to be on, not user logged, for the service to run
- A policy on failure can be defined (try to restart n times run a specific program if fails)
- A dependency can be defined (if you depend on other sevices)
- You can wrap your script in an invisible window
- You can easily start/stop/restart the script (
net start <scriptname>
)
从这里引用: 将应用程序开发为Windows服务的好处是什么?
这篇关于使用Windows服务或控制台应用程序好吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文