Skip to content

Commit

Permalink
Fix InvalidOp when enumerating the SystemClockChanged hashset
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd committed Apr 8, 2019
1 parent 04d98ea commit c889767
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Rx.NET/Source/src/System.Reactive/Internal/SystemClock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ private static void OnSystemClockChanged(object sender, SystemClockChangedEventA
{
lock (SystemClockChanged)
{
foreach (var entry in SystemClockChanged)
// create a defensive copy as the callbacks may change the hashset
var copySystemClockChanged = new List<WeakReference<LocalScheduler>>(SystemClockChanged);
foreach (var entry in copySystemClockChanged)
{
if (entry.TryGetTarget(out var scheduler))
{
Expand Down

0 comments on commit c889767

Please sign in to comment.