Skip to content

Commit

Permalink
Reduce ObjectDisposedException
Browse files Browse the repository at this point in the history
  • Loading branch information
kenelin committed Oct 19, 2021
1 parent 6c2a80d commit 8cfd6fb
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions source/Htc.Vita.Core/Auth/DefaultOAuth2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,21 @@ private void HandleHttpRequest(object o)
{
return;
}
if (Disposed)
{
return;
}

if (_cancellationToken.IsCancellationRequested)
{
_countdownEvent.Signal();
try
{
_countdownEvent.Signal();
}
catch (ObjectDisposedException)
{
Logger.GetInstance(typeof(DefaultAuthorizationCodeReceiver)).Error("Can not access disposed CountdownEvent");
}
}

var request = httpListenerContext.Request;
Expand Down Expand Up @@ -308,7 +319,14 @@ private void HandleHttpRequest(object o)
SpinWait.SpinUntil(() => false, TimeSpan.FromMilliseconds(200));

_shouldKeepListening = false;
_countdownEvent.Signal();
try
{
_countdownEvent.Signal();
}
catch (ObjectDisposedException)
{
Logger.GetInstance(typeof(DefaultAuthorizationCodeReceiver)).Error("Can not access disposed CountdownEvent");
}
}

/// <inheritdoc />
Expand Down

0 comments on commit 8cfd6fb

Please sign in to comment.