Skip to content

Commit dcbaf1e

Browse files
committed
Made GetRunningTasks safe thread.
1 parent bf44cc0 commit dcbaf1e

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

TaskExecutor/ActiveTaskRegistry.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,12 @@ public void Add(Task task)
7373
/// <returns>An array of <see cref="Task"/> objects that are currently running.</returns>
7474
public Task[] GetRunningTasks()
7575
{
76-
return _runningTasks
76+
lock (_lock)
77+
{
78+
return _runningTasks
7779
.Where(t => t.IsRunning && t.TaskReference != null)
7880
.Select(t => t.TaskReference!)
7981
.ToArray();
82+
}
8083
}
8184
}

0 commit comments

Comments
 (0)