diff --git a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs index 7eb877cba2ec03..ea2ca4b5f0e7ad 100644 --- a/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs +++ b/src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs @@ -43,7 +43,7 @@ public virtual Task StartAsync(CancellationToken cancellationToken) _stoppingCts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); // Execute all of ExecuteAsync asynchronously, and store the task we're executing so that we can wait for it later. - _executeTask = Task.Run(() => ExecuteAsync(_stoppingCts.Token), _stoppingCts.Token); + _executeTask = Task.Factory.StartNew(() => ExecuteAsync(_stoppingCts.Token), _stoppingCts.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default); // Always return a completed task. Any result from ExecuteAsync will be handled by the Host. return Task.CompletedTask;