Expose BackgroundService.ExecuteTask (#42981)
authorEric Erhardt <eric.erhardt@microsoft.com>
Tue, 6 Oct 2020 17:23:31 +0000 (12:23 -0500)
committerGitHub <noreply@github.com>
Tue, 6 Oct 2020 17:23:31 +0000 (12:23 -0500)
commite18d25e1a81d359097371615ff1a3407597c0bb3
tree829e7571b2053f55fdfc72f53ca7051cd366f282
parentd4c28607e4f4fd4e41df643e90579c56615a526f
Expose BackgroundService.ExecuteTask (#42981)

* Expose BackgroundService.ExecuteTask

Expose the task that executes the background service, so consumers can check if it is running and/or has ran to competition or faulted.

Use the new ExecuteTask to log exceptions when a BackgroundService fails after await, instead of appearing to hang.

Fix #35991
Fix #36017
src/libraries/Microsoft.Extensions.Hosting.Abstractions/ref/Microsoft.Extensions.Hosting.Abstractions.cs
src/libraries/Microsoft.Extensions.Hosting.Abstractions/src/BackgroundService.cs
src/libraries/Microsoft.Extensions.Hosting/Microsoft.Extensions.Hosting.sln
src/libraries/Microsoft.Extensions.Hosting/src/Internal/Host.cs
src/libraries/Microsoft.Extensions.Hosting/src/Internal/HostingLoggerExtensions.cs
src/libraries/Microsoft.Extensions.Hosting/src/Internal/LoggerEventIds.cs
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/BackgroundServiceTests.cs [moved from src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/BackgroundHostedServiceTests.cs with 95% similarity]
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/HostBuilderTests.cs
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/HostTests.cs
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/Internal/HostTests.cs
src/libraries/Microsoft.Extensions.Hosting/tests/UnitTests/TestEventListener.cs [new file with mode: 0644]