Skip to content

Instantly share code, notes, and snippets.

@cilliemalan
Created November 18, 2019 11:53
Show Gist options
  • Save cilliemalan/a10c3f8c3d7a1b97989b5680442eb1f8 to your computer and use it in GitHub Desktop.
Save cilliemalan/a10c3f8c3d7a1b97989b5680442eb1f8 to your computer and use it in GitHub Desktop.
public class MyBackgroundService : BackgroundService
{
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
using var disposer = messageQueue.Subscribe(async (msg) =>
{
await ProcessMessageAsync(msg, stoppingToken);
});
// Nasty!
while (!stoppingToken.IsCancellationRequested)
{
await Task.Delay(1000000, stoppingToken);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment