Windows服务VS控制台应用程序 [英] Windows service VS console application

查看:266
本文介绍了Windows服务VS控制台应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello团队,

我需要开发样本目录轮询应用程序,该应用程序可以从WEB应用程序进行配置,这是目录轮询和服务管理的最佳方法

(Widows服务)或控制台APP)



01.一个文件将在某个时间间隔到达的共享位置

02.需要编写样本应用程序关注那条路径并处理文件

03.并且Web应用程序用户想要更改文件位置,池化时间,

启动,停止等





目录轮询Windows服务或控制台应用程序的最佳方法是什么?

这样可以使用WEB应用程序控制



问候

Amitsinh



我尝试过:



我没有尝试任何东西,但我想到控制台应用程序让我知道哪个是好的窗口服务或控制台应用程序?

解决方案

要检测文件创建和更改,请使用 FileSystemWatcher类(System.IO) [ ^ ]。



我建议从控制台应用程序开始,因为这样更容易测试调试。为任务创建函数,以便以后决定使用服务时可以简单地复制它们。



如果最终应该使用服务或控制台应用程序是足够的取决于您的要求(例如何时启动,使用哪个帐户,支持重新启动和/或停止,以及如何与Web应用程序进行交互)。


听起来像一项服务会让你更好。该服务可以使用FileSystemWatcher来监视文件以进行更改并做出相应的反应。对于通过网站(或其他任何)进行控制,该服务可以托管WCF服务,允许其他内容通过标准Web服务进行通信。



正如Jochen所说,开发时将它们作为控制台应用程序启动是很好的,因为它可以更快,更容易地开发和调试它们,并且当您希望代码正常工作时创建服务并将代码复制到其中。请记住,控制台应用程序可以做一些服务无法访问桌面,使用交互式用户配置启动应用程序等的事情,所以只是保持代码中的东西,你应该没问题,当它是一个服务。

Hello team,
I need to develop the sample directory polling application which is configurable from WEB application which is best approach for Directory polling and Service Management
(Widows service or Console APP )

01. One Shared location where file will come at some interval
02. Need to Write sample app which will keep eye on that path and process the file
03. And Web application user want to change file location , Pooling timing ,
start ,stop etc


Which is best approach for directory polling Windows service or Console application ?
so that That can be controlled using WEB application

Regards
Amitsinh

What I have tried:

I have not tried any thing but am thinking of console application let me know which is good window service or console app ?

解决方案

For detecting file creation and changes use the FileSystemWatcher Class (System.IO)[^].

I suggest starting with a console application because that is easier to test and debug. Create functions for the tasks so that they can be simply copied if you decide later to use a service.

If a service should be finally used or a console application is sufficient depends on your requirements (like when to be started, which account to be used, support for restart and/or stop, and how the interaction with the web application is done).


Sounds like a service will do you better. The service can use a FileSystemWatcher to keep an eye on the file for changes and react accordingly. For control via a website (or anything else) the service can host an WCF service that allows other things to communicate via standard web services.

As Jochen said, when developing services it's good to start them as console apps as it is far quicker and easier to develop and debug them, and when you have the code working as you want create a service and copy the code into it. Just keep in mind the console app can do things a service can't like access the desktop, use the interactive users config to launch apps etc., so just keep things like that out of the code and you should be ok when it is a service.


这篇关于Windows服务VS控制台应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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