[FIX] Attempted fix for #1

This commit is contained in:
TheXorog 2022-05-14 20:33:53 +02:00
parent ba88ef438a
commit 82bbf70525
2 changed files with 17 additions and 2 deletions

View file

@ -255,7 +255,22 @@ public static class UniversalExtensions
task.Start();
});
registeredScheduledTasks.Add(UID, new taskInfo { tokenSource = CancellationToken, customId = CustomId, runTime = runTime});
if (registeredScheduledTasks is null)
registeredScheduledTasks = new();
try
{
registeredScheduledTasks.Add(UID, new taskInfo { tokenSource = CancellationToken, customId = CustomId, runTime = runTime });
}
catch (InvalidOperationException)
{
registeredScheduledTasks = new();
registeredScheduledTasks.Add(UID, new taskInfo { tokenSource = CancellationToken, customId = CustomId, runTime = runTime });
}
catch (Exception)
{
throw;
}
return UID;
}