Skip to content

Commit

Permalink
fix(Swarm): do not delay on SynchonizationContext
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed May 3, 2019
1 parent bb32760 commit d050696
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Swarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -889,10 +889,6 @@ public async Task StopListeningAsync(MultiAddress address)
if (!listener.IsCancellationRequested)
{
listener.Cancel(false);

// Give some time away, so that cancel can run.
// TODO: Would be nice to make this deterministic.
await Task.Delay(TimeSpan.FromMilliseconds(100));
}

// Remove any local peer address that depend on the cancellation token.
Expand All @@ -910,6 +906,10 @@ public async Task StopListeningAsync(MultiAddress address)
{
listeners.TryRemove(other, out CancellationTokenSource _);
}

// Give some time away, so that cancel can run
// TODO: Would be nice to make this deterministic.
await Task.Delay(TimeSpan.FromMilliseconds(100)).ConfigureAwait(false);
}
catch (Exception e)
{
Expand Down

0 comments on commit d050696

Please sign in to comment.