如何在以下代码示例的任务中调用 URL 获取请求。60 秒后urlhttp://mysite/SMS/SendText
没有被调用。
private static CacheItemRemovedCallback OnCacheRemove = null;
private void AddTask(string name, int seconds)
{
OnCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved);
HttpRuntime.Cache.Insert(name, seconds, null,
DateTime.Now.AddSeconds(seconds), Cache.NoSlidingExpiration,
CacheItemPriority.NotRemovable, OnCacheRemove);
}
public void CacheItemRemoved(string k, object v, CacheItemRemovedReason r)
{
// do stuff here if it matches our taskname, like WebRequest
// re-add our task so it recurs
AddTask(k, Convert.ToInt32(v));
}
protected void Application_Start()
{
AddTask("http://localhost:1901/SMS/SendText", 60);
}