[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

@ -88,7 +88,7 @@ internal static class Internal
public class InternalSheduler
{
public static Dictionary<string, taskInfo> registeredScheduledTasks { get; private set; } = new Dictionary<string, taskInfo>();
public static Dictionary<string, taskInfo> registeredScheduledTasks { get; internal set; } = new Dictionary<string, taskInfo>();
public class taskInfo
{

View file

@ -255,7 +255,22 @@ public static class UniversalExtensions
task.Start();
});
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;
}