Refactor LocalScheduler task removal and disable multitenancy

Refactored `RemoveScheduledTask` and `RemoveScheduledTasks` in `LocalScheduler.cs` to improve consistency and correctness in task management. Disabled multitenancy in `Program.cs` by setting `useMultitenancy` to false.
This commit is contained in:
Sipke Schoorstra 2024-10-29 10:09:37 +01:00
parent d3d171f59f
commit 123a95c07c
2 changed files with 8 additions and 7 deletions

View file

@ -68,7 +68,7 @@ const bool useSignalR = true;
const WorkflowRuntime workflowRuntime = WorkflowRuntime.ProtoActor;
const DistributedCachingTransport distributedCachingTransport = DistributedCachingTransport.ProtoActor;
const MassTransitBroker massTransitBroker = MassTransitBroker.Memory;
const bool useMultitenancy = true;
const bool useMultitenancy = false;
const bool useAgents = true;
const bool useSecrets = true;

View file

@ -66,11 +66,12 @@ public class LocalScheduler : IScheduler
private void RemoveScheduledTask(string name)
{
if (!_scheduledTasks.TryGetValue(name, out var existingScheduledTask))
return;
existingScheduledTask.Cancel();
_scheduledTaskKeys.Remove(existingScheduledTask);
if (_scheduledTasks.TryGetValue(name, out var existingScheduledTask))
{
_scheduledTaskKeys.Remove(existingScheduledTask);
_scheduledTasks.Remove(name);
existingScheduledTask.Cancel();
}
}
private void RemoveScheduledTasks(IEnumerable<string> keys)
@ -81,9 +82,9 @@ public class LocalScheduler : IScheduler
foreach (var scheduledTask in scheduledTasks)
{
scheduledTask.Cancel();
_scheduledTasks.RemoveWhere(x => x.Value == scheduledTask);
_scheduledTaskKeys.Remove(scheduledTask);
scheduledTask.Cancel();
}
}
}