Skip to content

Instantly share code, notes, and snippets.

@ankitvijay
Created February 21, 2021 19:54
Show Gist options
  • Save ankitvijay/b6414679abc87af7f798c0aba49d4c17 to your computer and use it in GitHub Desktop.
Save ankitvijay/b6414679abc87af7f798c0aba49d4c17 to your computer and use it in GitHub Desktop.
Scoped Scheduler Service
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