Created
September 4, 2018 15:35
-
-
Save fugaku/f2aa124a19c85ebcb4e30a63173a153f to your computer and use it in GitHub Desktop.
Worker Hosted 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
public class WorkerHostedService : BackgroundService | |
{ | |
protected override async Task ExecuteAsync(CancellationToken stopToken) | |
{ | |
//Do your preparation (e.g. Start code) here | |
while (!stopToken.IsCancellationRequested) | |
{ | |
await DoSomethingAsync(); | |
} | |
//Do your cleanup (e.g. Stop code) here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment