summary refs log tree commit diff
path: root/MatrixSystemdBridge/Worker.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MatrixSystemdBridge/Worker.cs')
-rw-r--r--MatrixSystemdBridge/Worker.cs24
1 files changed, 24 insertions, 0 deletions
diff --git a/MatrixSystemdBridge/Worker.cs b/MatrixSystemdBridge/Worker.cs
new file mode 100644

index 0000000..ee23c79 --- /dev/null +++ b/MatrixSystemdBridge/Worker.cs
@@ -0,0 +1,24 @@ +namespace MatrixSystemdBridge; + +public class Worker : BackgroundService +{ + private readonly ILogger<Worker> _logger; + + public Worker(ILogger<Worker> logger) + { + _logger = logger; + } + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + while (!stoppingToken.IsCancellationRequested) + { + if (_logger.IsEnabled(LogLevel.Information)) + { + _logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); + } + + await Task.Delay(1000, stoppingToken); + } + } +} \ No newline at end of file