开发者

Is there a way to call a method on an HTTPModule from a web page?

I'm using an HTTPModule to do some simple work in the background of a web application. I'm using a timer similar to what is described in this article: Using an HTTPModule to run a Background Service.

The problem is that the worker process never seems to terminate on its own, if no one's accessed the site in a long while. I figure the problem is that the timer is never halted even after it's clear that there's no more work to do. I can stop it, no problem, but I don't know a good way to know for sure when to restart it. I'd like to have a method that I can call from the particular page that would be the "kick off" point for this process. I suppose I could, alternatively, monitor BeginRequest for some URL to use as the trigger, but that feels kludgy.

I thought I was there with something like the line below, but something isn't right and I can't figure it out. DirectCast(System.Web.HttpModuleCollection.Item("TimerBasedHTTPModule"), TimerBasedHTTPModule)开发者_高级运维.StartPolling()

Suggestions?


I was close.

In my particular situation, this was the code I needed:

DirectCast(HttpContext.Current.ApplicationInstance.Modules.Item("TimerBasedHTTPModule"), TimerBasedHTTPModule).StartPolling()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜