Skip to content
This repository has been archived by the owner on Mar 7, 2019. It is now read-only.

Commit

Permalink
fixed a ObjectDisposedException on cancellation token source (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet authored and kenakamu committed Apr 18, 2018
1 parent cb5f742 commit 317476a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions UCWASDK/UCWASDK/Services/HttpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,11 @@ static public async Task Put(string uri, UCWAModelBase body, CancellationToken c
{
await ExecuteHttpCallAndRetry((token) => PutInternal(uri, body, token, version, anonymous), cancellationToken);
}
private static readonly CancellationTokenSource cts = new CancellationTokenSource();
private static CancellationTokenSource cts = new CancellationTokenSource();
static internal CancellationToken GetNewCancellationToken()
{
if (cts == null)
cts = new CancellationTokenSource();
return cts.Token;
}
[Obsolete]
Expand Down Expand Up @@ -206,7 +208,8 @@ static public void DisposeHttpClients()
{
foreach (var client in clientPool.Values)
client.Dispose();
cts.Dispose();
cts?.Dispose();
cts = null;
clientPool.Clear();
_anonymousHttpClient?.Dispose();
_anonymousHttpClient = null;
Expand Down

0 comments on commit 317476a

Please sign in to comment.