有什么方法可以在Asp.net应用程序中实现计划的操作? [英] Is there any way I can implement a Scheduled operation in Asp.net application?

查看:48
本文介绍了有什么方法可以在Asp.net应用程序中实现计划的操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要为Asp.net应用程序实现计划的操作,并且由于某些原因,我不想实现Windows服务或Windows的计划任务或数据库的计划操作.


解决方案

绝对可以!

您可以利用Asp.net Cache 来实现.这是您需要实现的事情的顺序:

1.在Cache中添加一个仲裁项,并指定一个持续时间.另外,指定一个CacheItemRemovedCallBack 处理程序.

2.当项目过期时,Asp.net运行时将调用CacheItemRemovedCallBack 处理程序方法.在该方法中,您可以执行所需的操作,然后将该项重新插入到Cache中,并使用相同的CacheItemRemovedCallBack 处理程序指定相同的持续时间.

因此,每次商品过期时,它都会调用回调方法,执行所需的操作,然后再次将商品插入Cache 中,以便商品可以再次过期(以模仿计划的活动).

您可以在下面的漂亮文章中查看有关该方法的更多信息:

使用ASP.NET模拟Windows服务以运行计划的作业 [ 解决方案

Definitely you can!

You can utilize the Asp.net Cache to achieve this. Here is the sequence of things you need to implement:

1. Add an arbitraty item in the Cache, along with specifying a duration time. Also, specify a CacheItemRemovedCallBack handler.

2. When the item gets expired, the Asp.net runtime will invoke the CacheItemRemovedCallBack handler method. Within the method, you perform your desired operation, and, re-insert the item in the Cache along with specifying the same duration time with the same CacheItemRemovedCallBack handler.

So, each time the items is expired, it calls the callback method, performs the desired operation, and, the item gets inserted into the Cache again so that it can expire again (To mimic the scheduled activity).

You can have a look in the following nice article to learn more about the approach:

Simulate a Windows Service using ASP.NET to run scheduled jobs[^]


这篇关于有什么方法可以在Asp.net应用程序中实现计划的操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发语言最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆