Custom Timed Events
Posted: Thu Jul 11, 2013 8:16 am
I would like to set up a timed event, so I followed the instructions here: http://wiki.ablecommerce.com/index.php/ ... med_Events.
I set up a variable:
I initialized it in Application_Start:
I modified the TimedEvent code to work in Gold (I think), so it looks like the following:
I do not get any entries in the app.log file, so I have the following questions:
1. Did I modify the code correctly for Gold?
2. What else do I need to do to get this to work?
I set up a variable:
Code: Select all
private System.Threading.Timer _timer2;
Code: Select all
_timer2 = new System.Threading.Timer(new System.Threading.TimerCallback(TimedEvent), null, 60000, 60000);
Code: Select all
private void TimedEvent(Object stateInfo)
{
// THIS IS RUNNING ON ITS OWN THREAD, OUTSIDE OF HTTPCONTEXT
// (HTTPCONTEXT.CONTEXT IS NULL)
// YOU MUST INITIALIZE THE TOKEN FOR THE STORE, CHANGE THE ID IF IT IS OTHER THAN 1
Store store = StoreDataSource.Load(1);
// INITIALIZE THE TOKEN FOR THIS STORE
// Token.Instance.InitStoreContext(store);
AbleContext.Current.Store = store;
// *********
// PUT YOUR CODE BELOW THIS COMMENT
// *********
Logger.Info("Timed task is running...");
// *********
// PUT YOUR CODE ABOVE THIS COMMENT
// *********
// RESET THE TOKEN INSTANCE AFTER THE EVENT RUNS
// Token.ResetInstance();
AbleContext.Current.Store = null;
}
1. Did I modify the code correctly for Gold?
2. What else do I need to do to get this to work?