如何将控制台应用程序转换为作为服务运行? [英] How to convert console application to run as a service?

查看:526
本文介绍了如何将控制台应用程序转换为作为服务运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将控制台应用程序转换为作为服务运行?我有控制台应用程序正在工作,如何使同一应用程序作为服务运行?

解决方案

这取决于您的控制台应用程序当前正在执行的操作.通常,如果需要某种TCP服务,远程服务器,WCF服务等,则需要一种服务.本质上,您具有可以在需要时激活的代码.既然您已经提出了这个问题,我想我们可以假设您现在拥有一个控制台应用程序,该应用程序会阻塞(也许在按键时)并保持线程处于活动状态.如果是这样,请遵循Nijboer的建议.如果不是,则需要说明您要实现的目标.


~~~~~~~~~~~

根据OP的评论,这里是指向文章的链接,该文章显示了如何使用VB.NET创建和安装服务:

http://msmvps.com/博客/joacim/archive/2009/09/13/creating-a-windows-service-using-vb-net.aspx [ 解决方案

It depends on what your console app does right now. Typically you''d need a service if you need some kind of TCP service, remoting server, WCF service etc. Essentially you have code that can be activated when desired. Since you''ve asked this question I guess we can assume that right now you have a console app, that blocks (perhaps on a key-press) and keeps a thread alive. If so, follow Nijboer''s suggestions. If not, you need to explain what you are trying to achieve.

[Edit]
~~~~~~~~~~~

Based on OP''s comment, here''s a link to an article that shows how to create and install a service using VB.NET:

http://msmvps.com/blogs/joacim/archive/2009/09/13/creating-a-windows-service-using-vb-net.aspx[^]


You simply create a service project and instead of writing to the console you write to the message log. There are many examples/articles on how this can be done.

Good luck!


这篇关于如何将控制台应用程序转换为作为服务运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆