将控制台应用程序转换为服务 [英] convert a console application to service

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

问题描述

我需要编写一个后端作业,该作业将读取csv并根据某些逻辑调用Web服务.该作业应安排为每天运行一次.
我已经为读取csv文件并调用webservice的逻辑编写了一个控制台应用程序.
现在我需要为此创建服务.
我应该创建Windows服务并在其中复制代码还是
有什么方法可以将控制台应用程序转换为服务或
我应该使用Windows Scheduler吗?

请帮忙,因为我是C#的新手.

I need to write a backend job which will read a csv & call a webservice based on some logic. This job should be scheduled to run once daily.
I have written a console application for the logic which is reading a csv file & calling webservice.
Now i need to create a service for this.
Should i create a windows service & copy my code there or
is there any way of converting console application into service or
should i use windows scheduler?

please help as i am new to C#.

推荐答案

我认为将控制台应用程序转换为服务不是明智的决定.因为服务是意味着要进行其他操作,而不是安排工作....如果将控制台转换为Windows服务,则需要编写一些自定义代码以使Windows服务每天运行一次..在这种情况下,最好的选择是使用Windows调度程序服务并将其指向控制台应用程序,而不是创建Windows服务.如果您除了计划之外还有其他要求或必要性,请告诉我...
I believe it will not be a wise decision to convert the console application to a service....cause service is meant for something else rather than job scheduling....in case you convert the console to a windows service you need to write some custom code to make the windows service run once per day..in this scenario the best option will be using windows scheduler service and point it to the console application rather than creating a windows service. If you have any other requirement or necessity besides the scheduling thing...please let me know...


Thanku.我的问题已解决.如果有人想知道如何在Windows Task Scheduler中安排作业,请参考:
http://www.onlinetoolworks.com/docs/winTaskSched.doc [
Thanku. My issue is resolved. If anyone wants to know how to schedule a job in windows task scheduler, please refer:
http://www.onlinetoolworks.com/docs/winTaskSched.doc[^]


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

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