如何定期做一下ASP.NET/WCF? [英] How to do something periodically in ASP.NET/WCF?

查看:77
本文介绍了如何定期做一下ASP.NET/WCF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有不好意思问这样一个愚蠢的问题:首先,我在asp.net相当新手。

First of all sorry of asking such a dumb question, I am quite a newbie in asp.net.

所以,我应该定期做一些事情,说我的网站heartpatients.com(假设)的老板,我想对每个谁访问该网站我的网站的用户,以2小时后,显示信息你拿丸。所以,基本上这就是我所有的问题,我怎么显示每2小时后,该邮件(或4,6任何时间)后,还我怎么可以自定义的时间。结果
还有一件事,说,如果我有一个WCF服务,显示此消息,我怎么能叫该服务在特定时间这个方法,即使用户(比如10小时后,有人吃药?)所以配置如何调用服务(在服务,尤其是法)由用户指定的时间周期过后?

So, I am supposed to do something periodically, say I am owner of site heartpatients.com (hypothetically) and I want that for each of my site user who visits the site, a message to be shown after 2hrs "Take your pills". so, basically this is all my question, how am I supposed to show this message after every 2hr (or 4, 6 whatever time)after, also how can I customize time.
One more thing, say if I have this method in a WCF service, that shows this message, how can I call that service at a particular time, and that even configured by user (say someone is taking pills after 10hrs?) So how to call that service (that particular method in service) after the time specified by user passes periodically?

我希望我做我的问题很清楚。结果
任何帮助是AP preciated。

I hope I made my question quite clear.
Any help is appreciated.

推荐答案

ASP.NET一般不适合作为一个任务调度。织物的性质是作为请求/响应系统。因此,一个Web应用程序的的只是坐着等待的请求,生成响应,并完成。

ASP.NET generally isn't suited as a task scheduler. The nature of the web is as a request/response system. So a web application should just sit and wait for a request, generate a response, and be done.

有关任何一种后端预定的任务,我建议你可以:

For any kind of back-end scheduled task, I'd recommend either:


  1. 系统 Windows服务

  2. 计划运行控制台应用程序(我认为Windows自带的任务调度程序)

有利弊两种方式。例如,Windows服务将启动时运行,没有控制台UI,一般是从服务器的角度非常易于管理。虽然控制台应用程序是传统简单的编写和调试。

There are pros and cons either way. For example, a Windows Service will run from boot time and has no console UI, and is generally very manageable from a server perspective. While a console application is traditionally simpler to write and debug.

这些仍然可以从Web应用程序共享code。如果你的业务逻辑和数据访问和所有的好东西都在自己的项目/组件那么这些其他应用程序可以使用这些组件一样好。 (当然,如果一切都在你的Web应用程序的用户界面结合,这是另一个问题完全。)

These can still share code from your web application. If your business logic and data access and all that good stuff are in their own projects/assemblies then these other applications can use those assemblies just as well. (Of course, if everything in your web application is UI-bound, that's another question entirely.)

什么我最关心的是......你怎么打算的显示的这个消息给用户?被用户只需坐在你的网站了几个小时的时间和你需要提醒他们采取他们吃药?还是你打算发送电子邮件或东西吗?也许你给了并没有真正解释你想要做什么的例子吗?我不知道。

What concerns me the most is... How do you plan to show this message to a user? Is the user just sitting on your website for hours at a time and you need to remind them to take their meds? Or do you plan to send an email or something? Maybe the example you gave doesn't really explain what you're trying to do? I'm not sure.

在后台运行的任务是一回事,但在我看来,你的整体式的整个半(显示消息给用户)是有点发呆,不是真的以为通过。

Running tasks in the background is one thing, but it seems to me that an entire half of your overall equation (displaying a message to the user) is sort of glazed over and not really thought through.

这篇关于如何定期做一下ASP.NET/WCF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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