Last active
October 7, 2019 10:41
-
-
Save schmitch/60f870aeb6fb668fe304d959bb580e9e to your computer and use it in GitHub Desktop.
Is it possible
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 BackgroundQueuedHostedService : BackgroundService | |
{ | |
protected override async Task ExecuteAsync(CancellationToken cancellationToken) | |
{ | |
while (!cancellationToken.IsCancellationRequested) | |
{ | |
var workItem = await TaskQueue.DequeueAsync(cancellationToken); | |
await FastTask(); // | |
await Task.Factory.StartNew( | |
() => | |
{ | |
// Blocking call | |
}, | |
CancellationToken.None, | |
TaskCreationOptions.LongRunning & TaskCreationOptions.DenyChildAttach, | |
TaskScheduler.Default); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment