软件程序员

编程入门 行业动态 更新时间:2024-10-22 20:29:39
本文介绍了软件程序员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个网站(这是我的第一个网站)。该站点应该从安装并分散在现场的硬件控制器中轮询和存储数据。

I am developing a web(this my first site). this site is supposed to poll and store data from hardware controllers which are installedand dispersed in the field.

是否可能网站中的代码可以在即使没有客户端连接到站点,或者我必须编写一个单独的程序来轮询控制器并填满数据库,然后在连接a客户端时读取数据库。

Isit possible that the code in the web site could run this task in the background even if no client is connected to the site, or do I have to write a separate program which poll the controller and fill up a database, and then read the database when a client is connected.

当然我更喜欢第一个选项。

Of courseI prefer the the first option.

提前谢谢

David Anidjar

David Anidjar

推荐答案

It取决于你正在使用什么技术。

在基于.NET Framework的Web应用程序(Asp)中,计时器经常用于按计划的时间间隔执行活动,因此使用计时器似乎是适当的我的解决方案。 您可以从 Global.asax 中的 Application_Start 处理程序启动计时器来运行计划任务。遗憾的是,此解决方案通过应用程序域,进程或系统重新启动不稳定,因为必须向应用程序发出请求才能启动计时器。 ASP.NET是一种被动的编程范例,它只响应HTTP请求,因此进程或用户输入必须调用代码才能运行它。 这就是我不建议您采用第一种方法的原因。

In .NET Framework-based web applications (Asp), timers are frequently used to perform activities at scheduled intervals, so using one would seem to be an appropriate solution. You could start a timer from the Application_Start handler in Global.asax to run your scheduled tasks. Unfortunately, this solution is not robust through application domain, process, or system restarts because a request must be made to the application to start the timer. ASP.NET is a passive programming paradigm that only responds to HTTP requests, so a process or user input must call the code for it to run. This is the reason I would not recommend you to go with your first approach.

基本上,您可以编写Windows服务(单独的代码块)来汇集所需的数据。使用Windows服务的优点是可以直接使用托管的.NET 代码。

更多推荐

软件程序员

本文发布于:2023-10-07 15:05:29,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1469715.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:程序员   软件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!