Created
September 6, 2016 08:15
-
-
Save jhauge/75dc7355b5ce67e3ea0fd5af7bec7b3f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Web; | |
using System.Web.Caching; | |
namespace DriftinfoSystem | |
{ | |
public class Global : HttpApplication | |
{ | |
private const string DummyCacheItem = "SimpleWindowsService"; | |
private static CacheItemRemovedCallback _onCacheRemove; | |
protected void Application_Start(object sender, EventArgs e) | |
{ | |
AddTask(); | |
//AddTaskFetchDatabaseSync(); | |
} | |
/// <summary> | |
/// This task emulates a scheduled windows service as explained here: | |
/// </summary> | |
private void AddTask() | |
{ | |
_onCacheRemove = new CacheItemRemovedCallback(CacheItemRemoved); | |
HttpRuntime.Cache.Insert(DummyCacheItem, 120, null, | |
DateTime.Now.AddSeconds(120), Cache.NoSlidingExpiration, | |
CacheItemPriority.NotRemovable, _onCacheRemove); | |
} | |
public void CacheItemRemoved(string key, object value, CacheItemRemovedReason reason) | |
{ | |
EmailAgent.TriggerAgent(true); | |
AddTask(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment