* Add cancellation handling for executing scheduled tasks Enhanced `ScheduledRecurringTask`, `ScheduledCronTask`, and `ScheduledSpecificInstantTask` to properly handle cancellation scenarios when tasks are executing. Introduced `_executing` and `_cancellationRequested` flags to ensure clean cancellation processes. * Refactor `ScheduledRecurringTask` to improve readability and fix formatting issues. * Add `SemaphoreSlim` for concurrent task execution control in scheduled tasks Introduce `SemaphoreSlim` to manage and safeguard concurrent executions in `ScheduledRecurringTask`, `ScheduledCronTask`, and `ScheduledSpecificInstantTask`. Enhances thread safety and prevents overlapping executions. Added exception handling and proper semaphore release to ensure robustness. * Add ILogger to scheduled tasks and improve error logging Integrated `ILogger` into `ScheduledRecurringTask` to enhance logging capabilities and replaced the generic comment-based error handling with proper logging for better traceability. Cleaned up and formatted `ScheduledCronTask` for improved code readability. * Dispose of semaphore fields in scheduled task classes to ensure proper resource cleanup. * Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Set `_executing` to `false` in task `finally` blocks to ensure state reset after execution. * Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledSpecificInstantTask.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Remove redundant `_executing` assignment after `SendAsync` in scheduled task classes. * Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledCronTask.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledSpecificInstantTask.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update semaphore logic to prevent blocked tasks when cancellation is requested Refactored `_executionSemaphore.WaitAsync` usage in `ScheduledRecurringTask`, `ScheduledCronTask`, and `ScheduledSpecificInstantTask` to use non-blocking semaphore acquisition with cancellation token support. This ensures graceful handling of pending tasks during cancellation scenarios. * Refactor delay condition checks to use `TimeSpan.Zero` for improved readability and precision. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| apps | ||
| clients/Elsa.Api.Client | ||
| common | ||
| modules | ||
| Directory.Build.props | ||