elsa-core/src/modules/Elsa.Scheduling
Max Brooks 50a3dc7921
Enhance thread safety with ConcurrentDictionary usage (#6760)
* Enhance thread safety with ConcurrentDictionary usage

Replaced `IDictionary` with `ConcurrentDictionary` for
both `_scheduledTasks` and `_scheduledTaskKeys` to
improve thread safety in a multi-threaded environment.

Updated methods `RegisterScheduledTask`,
`RemoveScheduledTask`, and `RemoveScheduledTasks` to
utilize the `Remove` method of `ConcurrentDictionary`,
ensuring safe and efficient removal of scheduled tasks.

* Refactor task registration and removal logic

Updated `RegisterScheduledTask` to use `AddOrUpdate` for streamlined task management. This change simplifies the addition and updating of scheduled tasks by consolidating logic into a single operation. Introduced `RemoveScheduledTask` method to handle task removal by name, improving code organization and clarity.

* Improve task removal handling in LocalScheduler

Modified the `LocalScheduler` class to enhance the removal process of scheduled tasks from the `_scheduledTaskKeys` collection. The removal operation now captures the result in a variable and includes a conditional check to log a warning if the task was not found, improving error handling and debugging capabilities.

* Refactor task removal in LocalScheduler

Updated the removal process for scheduled tasks in `_scheduledTasks`.
The new implementation collects all corresponding keys and attempts to remove them individually, logging warnings for any failures. This enhances error handling and provides better debugging information.

---------

Co-authored-by: Max Brooks <Max@compyl.com>
2025-07-15 14:01:38 +02:00
..
Activities Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Bookmarks Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Commands Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Contracts Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Extensions Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Features Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Handlers Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
HostedServices Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Models Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Requests Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
ScheduledTasks Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Schedules Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Services Enhance thread safety with ConcurrentDictionary usage (#6760) 2025-07-15 14:01:38 +02:00
Tasks Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
TriggerPayloadValidators Create trigger payload validation, refacto HttpEndpoint validator and create Cron validator (#6641) 2025-05-20 19:52:43 +02:00
Elsa.Scheduling.csproj Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
Elsa.Scheduling.csproj.DotSettings Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
FodyWeavers.xml Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00
SchedulingStimulusNames.cs Remove Elsa.Expressions.Dsl module and related DSL features 2025-06-02 21:52:10 +02:00