Scoped Scheduler Service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.Extensions.Logging; | |
namespace SchedulerJobSample.Worker | |
{ | |
public interface IScopedSchedulerService | |
{ | |
Task ExecuteAsync(CancellationToken cancellationToken); | |
} | |
public class ScopedSchedulerService : IScopedSchedulerService | |
{ | |
private readonly ILogger<ScopedSchedulerService> _logger; | |
public ScopedSchedulerService(ILogger<ScopedSchedulerService> logger) | |
{ | |
_logger = logger; | |
} | |
public Task ExecuteAsync(CancellationToken cancellationToken) | |
{ | |
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now); | |
return Task.CompletedTask; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment