Skip to content

Commit

Permalink
Fix for jobs still considered running
Browse files Browse the repository at this point in the history
  • Loading branch information
Brunni committed Dec 22, 2020
1 parent 448c5ab commit 0f02264
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion AsyncScheduler/Scheduler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,17 @@ private async void ResolveTaskEnd(string jobKey, Task<object> task)
}
finally
{
_runningJobs.TryRemove(jobKey, out _);
bool removed;
do
{
removed = _runningJobs.TryRemove(jobKey, out _);
if (!removed)
{
_logger.LogWarning("Unable to remove running job from ConcurrentDictionary: {jobKey} ... Retry...", jobKey);
await Task.Delay(TimeSpan.FromMilliseconds(50));
}
} while (removed == false);

if (task is IDisposable disposable)
{
disposable.Dispose();
Expand Down

0 comments on commit 0f02264

Please sign in to comment.