如何在ASP.NET应用程序上运行计划任务 [英] How to run scheduled tasks on ASP.NET application
问题描述
大家好,
我有一个C#项目,它将数据记录到sql server数据库并监视windows窗体上的实时数据,C#项目从中读取数据通过以太网套接字的TCP / IP设备,我发送命令并每隔1秒从流中读取响应。使用Windows窗体计时器。
第二个计时器间隔= 5(min),其中数据保存在sql server中。
i希望将其转换为asp.net,让用户访问服务器来自任何地方的网站。
当我使用asp.net时,在服务器端执行此操作的最佳方式是什么,或者从哪里可以开始连接并获取来自我在C#项目中的设备数据。
我尝试过:
我尝试过篝火。但是有一种方法可以在后台运行任务。
Hi All,
I have a C# project that logging data into sql server database and monitor the real time data on windows form, the C# project read data from TCP/IP Devices over ethernet socket, where i send the command and read the response from stream every (1) sec. using windows form timer.
And the second timer interval = 5 (min) where the data saved in the sql server.
i want to convert this to asp.net to let user access the server over a website from any where.
what is the best way to do this in the server side when i using asp.net or from where can i start to connect and get data from devices as i did in C# project.
What I have tried:
I have tried the hangfire. but is there a butter way to run task in background.
推荐答案
你可以尝试石英
[ https:// www .quartz-scheduler.net / ]
但是在Asp.net应用程序中运行后台任务是不可靠的,因为只有当你的web应用程序有活动请求或运行。
我使用Windows服务(C#)应用程序来运行后台任务
You can try quartz
[https://www.quartz-scheduler.net/]
But running a background task in Asp.net application is unreliable because it will only run if your web application has active requests or running.
I used windows service (C#) application to run background tasks
一种便宜又简单的方法是有一个特定的URL来触发任务,并使用PINGDOM等服务来命中该特定的URL。
A cheap and easy method is to have a specific URL to trigger the task, and use a service such as PINGDOM to hit that specific URL.
这篇关于如何在ASP.NET应用程序上运行计划任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!