Fix occasional internal ObjectDisposedException when disposing

This commit is contained in:
Noi 2021-06-01 21:47:54 -07:00
parent 59afd8ce3b
commit 88c18c4364
2 changed files with 6 additions and 2 deletions

View file

@ -76,7 +76,11 @@ namespace BirthdayBot.BackgroundServices
// Execute tasks sequentially
foreach (var service in _workers)
{
try { await service.OnTick(_workerCanceller.Token).ConfigureAwait(false); }
try
{
if (_workerCanceller.IsCancellationRequested) break;
await service.OnTick(_workerCanceller.Token).ConfigureAwait(false);
}
catch (Exception ex)
{
var svcname = service.GetType().Name;

View file

@ -19,7 +19,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Discord.Net" Version="2.3.0" />
<PackageReference Include="Discord.Net" Version="2.4.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NodaTime" Version="3.0.3" />
<PackageReference Include="Npgsql" Version="4.1.5" />