Set next execution time of ScheduledPlugIn at app start


I have a ScheduledPlugIn that I'd like to run the next minute (at the latest) after each time the application starts.

That post has all I need but isn't there a way to save a scheduled job item than to use a SqlCommand?

Aug 21, 2012 9:30

Is there any problem with calling the static Execute method of the class directly from application start? Otherwise that might be an option

Aug 21, 2012 10:43

If it's possible to call Execute async to not slow down app start it could be an option.

The job takes quite a while to finish so I'd like the scheduler to run it. I'd also prefer if the entered interval uses the app start time for later executions.

Aug 21, 2012 13:07

Either start a new thread and do it asynch or use the built in scheduler then I guess. To use the built in scheduler you can use something similar to this code in application start up... (using EPiServer.DataAbstraction)

 private void InitializeScheduledJob()
            const string fullTypeName = "PROJECT.Web.Plugins.ScheduledJobs.CLASS_NAME_OF_JOB";
            const string assemblyName = "PROJECT.Web";
            const string methodName = "Execute";
            var now = DateTime.Now;
            var job = ScheduledJob.Load(methodName, fullTypeName, assemblyName);
            job.NextExecution = now.AddMinutes(1);
            job.IntervalLength = 1;
            job.IntervalType = ScheduledIntervalType.Days;

Hope this helps

Aug 21, 2012 14:02

Looks like exactly what I need. Will try out later this week. Thanks!

Aug 21, 2012 14:25
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.