Skip to content

Commit 6a73232

Browse files
authored
Merge pull request #7199 from umbraco/version-update
Formatted IRecurringBackgroundJob section for better readability - other CMS versions
2 parents 1df5c51 + 3dd98b5 commit 6a73232

File tree

3 files changed

+135
-96
lines changed

3 files changed

+135
-96
lines changed

13/umbraco-cms/reference/scheduling.md

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,65 @@ Once you have created your background job class, register it using a Composer. I
1212
Be aware you may or may not want this background job to run on all servers. If you are using Load Balancing with multiple servers, see [load balancing documentation](../fundamentals/setup/server-setup/load-balancing/) for more information
1313
{% endhint %}
1414

15-
## `IRecurringBackgroundJob`
15+
## `IRecurringBackgroundJob` Properties and Methods
1616

17-
- `Period` - this property is a `TimeSpan` that tells Umbraco how often to run your job.
17+
### Period
1818

19-
```c#
20-
// Run this job every 5 minutes
21-
TimeSpan Period = TimeSpan.FromMinutes(5);
22-
```
19+
Defines how often the job runs. This property is a `TimeSpan`.
2320

24-
- `Delay` - this property is also a `TimeSpan` that tells Umbraco how long to wait after starting up before running the task for the first time. The default is 3 minutes.
21+
```csharp
22+
// Run this job every 5 minutes
23+
TimeSpan Period = TimeSpan.FromMinutes(5);
24+
```
2525

26-
```c#
27-
// Wait 3 minutes after application startup before starting to run this job.
28-
TimeSpan Delay = TimeSpan.FromMinutes(3);
29-
```
26+
### Delay
3027

31-
- `ServerRoles` - a list of roles that should run this job. In a multi-server setup you may want your job to run on _all_ servers, or only on _one_ of your servers.
32-
For example, a temporary file cleanup task might need to run on all servers. A database import job might be better to be run once per day on a single server.
28+
Defines how long to wait after application startup before running the task for the first time. Default is 3 minutes. This property is a `TimeSpan`.
3329

34-
The default value is: `{ Single, SchedulingPublisher }`, which will cause the job to only run on _one_ server.
30+
```csharp
31+
// Wait 3 minutes after application startup before starting to run this job.
32+
TimeSpan Delay = TimeSpan.FromMinutes(3);
33+
```
3534

36-
```c#
37-
// Run this job on ALL servers
38-
ServerRole[] ServerRoles = Enum.GetValues<ServerRole>();
39-
```
35+
### ServerRoles
4036

41-
For more information about server roles, see the [Load Balancing](../fundamentals/setup/server-setup/load-balancing#scheduling-and-server-role-election) documentation.
37+
Specifies a list of roles that should run this job. In a multi-server setup, you may want your job to run on _all_ servers or only on _one_ of your servers.
4238

43-
- `PeriodChanged` - an event you can trigger to tell the background job service that the period has changed. For example, if the period for your job is controlled by a configuration file setting.
39+
For example, a temporary file cleanup task might need to run on all servers. A database import job might be better to be run once per day on a single server.
4440

45-
```c#
46-
// No-op event as the period never changes on this job
47-
public event EventHandler PeriodChanged { add { } remove { } }
48-
```
41+
By default: `{ Single, SchedulingPublisher }`, meaning it runs on one server only.
4942

50-
See below for a full example of how to implement the PeriodChanged event.
43+
```csharp
44+
// Run this job on all servers
45+
ServerRole[] ServerRoles = Enum.GetValues<ServerRole>();
46+
```
5147

52-
- `RunJobAsync()` - the main method of your job.
48+
For more information about server roles, see the [Load Balancing](../fundamentals/setup/server-setup/load-balancing/README.md#scheduling-and-server-role-election) documentation.
5349

54-
```c#
55-
public Task RunJobAsync() {
56-
// your job code goes here
57-
}
58-
```
50+
### PeriodChanged
51+
52+
An event used to notify the background job service if the job’s period changes dynamically.
53+
54+
For example, if the period for your job is controlled by a configuration file setting, you can trigger the `PeriodChanged` event when the configuration changes.
55+
56+
```csharp
57+
// No-op event as the period never changes on this job
58+
public event EventHandler PeriodChanged { add { } remove { } }
59+
```
60+
61+
See the [Example](#example) below on how to implement the `PeriodChanged` event.
62+
63+
### RunJobAsync()
64+
65+
The main method where your job logic is implemented.
66+
67+
```csharp
68+
public Task RunJobAsync() {
69+
// your job code goes here
70+
}
71+
```
5972

60-
## Minimal example
73+
## Example
6174

6275
This example shows the minimum code necessary to implement the `IRecurringBackgroundJob` interface. The job runs every 60 minutes on all servers.
6376

14/umbraco-cms/reference/scheduling.md

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,65 @@ Once you have created your background job class, register it using a Composer. I
1212
Be aware you may or may not want this background job to run on all servers. If you are using Load Balancing with multiple servers, see [load balancing documentation](../fundamentals/setup/server-setup/load-balancing/) for more information
1313
{% endhint %}
1414

15-
## `IRecurringBackgroundJob`
15+
## `IRecurringBackgroundJob` Properties and Methods
1616

17-
- `Period` - this property is a `TimeSpan` that tells Umbraco how often to run your job.
17+
### Period
1818

19-
```c#
20-
// Run this job every 5 minutes
21-
TimeSpan Period = TimeSpan.FromMinutes(5);
22-
```
19+
Defines how often the job runs. This property is a `TimeSpan`.
2320

24-
- `Delay` - this property is also a `TimeSpan` that tells Umbraco how long to wait after starting up before running the task for the first time. The default is 3 minutes.
21+
```csharp
22+
// Run this job every 5 minutes
23+
TimeSpan Period = TimeSpan.FromMinutes(5);
24+
```
2525

26-
```c#
27-
// Wait 3 minutes after application startup before starting to run this job.
28-
TimeSpan Delay = TimeSpan.FromMinutes(3);
29-
```
26+
### Delay
3027

31-
- `ServerRoles` - a list of roles that should run this job. In a multi-server setup, you may want your job to run on _all_ servers, or only on _one_ of your servers.
32-
For example, a temporary file cleanup task might need to run on all servers. A database import job might be better to be run once per day on a single server.
28+
Defines how long to wait after application startup before running the task for the first time. Default is 3 minutes. This property is a `TimeSpan`.
3329

34-
The default value is: `{ Single, SchedulingPublisher }`, which will cause the job to only run on _one_ server.
30+
```csharp
31+
// Wait 3 minutes after application startup before starting to run this job.
32+
TimeSpan Delay = TimeSpan.FromMinutes(3);
33+
```
3534

36-
```c#
37-
// Run this job on ALL servers
38-
ServerRole[] ServerRoles = Enum.GetValues<ServerRole>();
39-
```
35+
### ServerRoles
4036

41-
For more information about server roles, see the [Load Balancing](../fundamentals/setup/server-setup/load-balancing#scheduling-and-server-role-election) documentation.
37+
Specifies a list of roles that should run this job. In a multi-server setup, you may want your job to run on _all_ servers or only on _one_ of your servers.
4238

43-
- `PeriodChanged` - an event you can trigger to tell the background job service that the period has changed. For example, if the period for your job is controlled by a configuration file setting.
39+
For example, a temporary file cleanup task might need to run on all servers. A database import job might be better to be run once per day on a single server.
4440

45-
```c#
46-
// No-op event as the period never changes on this job
47-
public event EventHandler PeriodChanged { add { } remove { } }
48-
```
41+
By default: `{ Single, SchedulingPublisher }`, meaning it runs on one server only.
4942

50-
See below for a full example of how to implement the PeriodChanged event.
43+
```csharp
44+
// Run this job on all servers
45+
ServerRole[] ServerRoles = Enum.GetValues<ServerRole>();
46+
```
5147

52-
- `RunJobAsync()` - the main method of your job.
48+
For more information about server roles, see the [Load Balancing](../fundamentals/setup/server-setup/load-balancing/README.md#scheduling-and-server-role-election) documentation.
5349

54-
```c#
55-
public Task RunJobAsync() {
56-
// your job code goes here
57-
}
58-
```
50+
### PeriodChanged
51+
52+
An event used to notify the background job service if the job’s period changes dynamically.
53+
54+
For example, if the period for your job is controlled by a configuration file setting, you can trigger the `PeriodChanged` event when the configuration changes.
55+
56+
```csharp
57+
// No-op event as the period never changes on this job
58+
public event EventHandler PeriodChanged { add { } remove { } }
59+
```
60+
61+
See the [Example](#example) below on how to implement the `PeriodChanged` event.
62+
63+
### RunJobAsync()
64+
65+
The main method where your job logic is implemented.
66+
67+
```csharp
68+
public Task RunJobAsync() {
69+
// your job code goes here
70+
}
71+
```
5972

60-
## Minimal example
73+
## Example
6174

6275
This example shows the minimum code necessary to implement the `IRecurringBackgroundJob` interface. The job runs every 60 minutes on all servers.
6376

15/umbraco-cms/reference/scheduling.md

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,52 +12,65 @@ Once you have created your background job class, register it using a Composer. I
1212
Be aware you may or may not want this background job to run on all servers. If you are using Load Balancing with multiple servers, see [load balancing documentation](../fundamentals/setup/server-setup/load-balancing/) for more information
1313
{% endhint %}
1414

15-
## `IRecurringBackgroundJob`
15+
## `IRecurringBackgroundJob` Properties and Methods
1616

17-
- `Period` - this property is a `TimeSpan` that tells Umbraco how often to run your job.
17+
### Period
1818

19-
```c#
20-
// Run this job every 5 minutes
21-
TimeSpan Period = TimeSpan.FromMinutes(5);
22-
```
19+
Defines how often the job runs. This property is a `TimeSpan`.
2320

24-
- `Delay` - this property is also a `TimeSpan` that tells Umbraco how long to wait after starting up before running the task for the first time. The default is 3 minutes.
21+
```csharp
22+
// Run this job every 5 minutes
23+
TimeSpan Period = TimeSpan.FromMinutes(5);
24+
```
2525

26-
```c#
27-
// Wait 3 minutes after application startup before starting to run this job.
28-
TimeSpan Delay = TimeSpan.FromMinutes(3);
29-
```
26+
### Delay
3027

31-
- `ServerRoles` - a list of roles that should run this job. In a multi-server setup, you may want your job to run on _all_ servers, or only on _one_ of your servers.
32-
For example, a temporary file cleanup task might need to run on all servers. A database import job might be better to be run once per day on a single server.
28+
Defines how long to wait after application startup before running the task for the first time. Default is 3 minutes. This property is a `TimeSpan`.
3329

34-
The default value is: `{ Single, SchedulingPublisher }`, which will cause the job to only run on _one_ server.
30+
```csharp
31+
// Wait 3 minutes after application startup before starting to run this job.
32+
TimeSpan Delay = TimeSpan.FromMinutes(3);
33+
```
3534

36-
```c#
37-
// Run this job on ALL servers
38-
ServerRole[] ServerRoles = Enum.GetValues<ServerRole>();
39-
```
35+
### ServerRoles
4036

41-
For more information about server roles, see the [Load Balancing](../fundamentals/setup/server-setup/load-balancing#scheduling-and-server-role-election) documentation.
37+
Specifies a list of roles that should run this job. In a multi-server setup, you may want your job to run on _all_ servers or only on _one_ of your servers.
4238

43-
- `PeriodChanged` - an event you can trigger to tell the background job service that the period has changed. For example, if the period for your job is controlled by a configuration file setting.
39+
For example, a temporary file cleanup task might need to run on all servers. A database import job might be better to be run once per day on a single server.
4440

45-
```c#
46-
// No-op event as the period never changes on this job
47-
public event EventHandler PeriodChanged { add { } remove { } }
48-
```
41+
By default: `{ Single, SchedulingPublisher }`, meaning it runs on one server only.
4942

50-
See below for a full example of how to implement the PeriodChanged event.
43+
```csharp
44+
// Run this job on all servers
45+
ServerRole[] ServerRoles = Enum.GetValues<ServerRole>();
46+
```
5147

52-
- `RunJobAsync()` - the main method of your job.
48+
For more information about server roles, see the [Load Balancing](../fundamentals/setup/server-setup/load-balancing/README.md#scheduling-and-server-role-election) documentation.
5349

54-
```c#
55-
public Task RunJobAsync() {
56-
// your job code goes here
57-
}
58-
```
50+
### PeriodChanged
51+
52+
An event used to notify the background job service if the job’s period changes dynamically.
53+
54+
For example, if the period for your job is controlled by a configuration file setting, you can trigger the `PeriodChanged` event when the configuration changes.
55+
56+
```csharp
57+
// No-op event as the period never changes on this job
58+
public event EventHandler PeriodChanged { add { } remove { } }
59+
```
60+
61+
See the [Example](#example) below on how to implement the `PeriodChanged` event.
62+
63+
### RunJobAsync()
64+
65+
The main method where your job logic is implemented.
66+
67+
```csharp
68+
public Task RunJobAsync() {
69+
// your job code goes here
70+
}
71+
```
5972

60-
## Minimal example
73+
## Example
6174

6275
This example shows the minimum code necessary to implement the `IRecurringBackgroundJob` interface. The job runs every 60 minutes on all servers.
6376

0 commit comments

Comments
 (0)