You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+155-7Lines changed: 155 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,39 @@ The Atc.Hosting namespace serves as a toolbox for building scalable and reliable
32
32
33
33
# BackgroundServiceBase`<T>`
34
34
35
-
The `BackgroundServiceBase<T>` class serves as a base for continuous long running background services that require enhanced features like custom logging and configurable service options. It extends the ASP.NET Core's `BackgroundService` class, providing a more robust framework for handling background tasks.
35
+
The `BackgroundServiceBase<T>` class serves as a base for continuous long running background services that require enhanced features like custom logging and configurable service options.
36
+
It extends the ASP.NET Core's `BackgroundService` class, providing a more robust framework for handling background tasks.
37
+
38
+
This class is based on repeat intervals.
39
+
40
+
# BackgroundScheduleServiceBase`<T>`
41
+
42
+
The `BackgroundScheduleServiceBase<T>` class serves as a base for continuous long running background services that require enhanced features like custom logging and configurable service options.
43
+
It extends the ASP.NET Core's `BackgroundService` class, providing a more robust framework for handling background tasks.
44
+
45
+
This class is based on cron expression for scheduling.
46
+
47
+
- More information about cron expressions can be found on [wiki](https://en.wikipedia.org/wiki/Cron)
48
+
- To get help with defining a cron expression, use this [cron online helper](https://crontab.cronhub.io/)
49
+
50
+
## Cron format
51
+
52
+
Cron expression is a mask to define fixed times, dates and intervals.
53
+
The mask consists of second (optional), minute, hour, day-of-month, month and day-of-week fields.
54
+
All of the fields allow you to specify multiple values, and any given date/time will satisfy the specified Cron expression, if all the fields contain a matching value.
55
+
56
+
```
57
+
Allowed values Allowed special characters Comment
58
+
59
+
┌───────────── second (optional) 0-59 * , - /
60
+
│ ┌───────────── minute 0-59 * , - /
61
+
│ │ ┌───────────── hour 0-23 * , - /
62
+
│ │ │ ┌───────────── day of month 1-31 * , - / L W ?
│ │ │ │ │ ┌───────────── day of week 0-6 or SUN-SAT * , - / # L ? Both 0 and 7 means SUN
65
+
│ │ │ │ │ │
66
+
* * * * * *
67
+
```
36
68
37
69
## Features
38
70
@@ -44,14 +76,15 @@ The `BackgroundServiceBase<T>` class serves as a base for continuous long runnin
44
76
### Error Handling
45
77
46
78
- Catches unhandled exceptions and logs them with a severity of `LogLevel.Warning`.
47
-
- Reruns the `DoWorkAsync` method after a configurable repeat interval.
79
+
- Reruns the `DoWorkAsync` method after a configurable `repeat interval` for `BackgroundServiceBase` or `scheduled` for `BackgroundScheduleServiceBase`.
48
80
- For manual error handling hook into the exception handling in `DoWorkAsync` by overriding the `OnExceptionAsync` method.
49
81
- Designed to log errors rather than crashing the service.
50
82
51
83
### Configuration Options
52
84
53
-
- Allows for startup delays.
54
-
- Configurable repeat interval for running tasks.
85
+
- Allows for `startup delays` for `BackgroundServiceBase`.
86
+
- Configurable `repeat interval` for running tasks with `BackgroundServiceBase`.
87
+
- Configurable `cron expression` for scheduling running tasks with `BackgroundScheduleServiceBase`.
55
88
56
89
### Ease of Use
57
90
@@ -74,6 +107,21 @@ public class MyBackgroundService : BackgroundServiceBase<MyBackgroundService>
0 commit comments