Episerver: Execute a Schedule Job within a schedule Job

439 Views Asked by At

Is it possible to execute a schedule job within a schedule job .For Instance ,I have a schedule job A that does some operations .There is another schedule job B that executes after Schedule Job A is executed. So rather than manually going and running the job using admin mode which is a straightforward option, Is there a way wherein I can execute job B after Job A is executed successfully? I found an interface IScheduledJobExecutor which looks like it does but i am not sure if this is advisible to do that. Any thoughts on this?

1

There are 1 best solutions below

2
On

I would not create dependencies between scheduled jobs like that. Instead, consider refactoring your code so that the business logic of both operations can be carried out in the same scheduled job.

So, let's say you refactor your code into Foo() and Bar().

Then create the following for maximum flexibility:

  1. Scheduled Job A which executes Foo() only
  2. Scheduled Job B which executes Bar() only
  3. Scheduled Job C which executes both Foo() and Bar()

Obviously, you might not need #1 and #2 unless there is good reason for executing the operations individually.