Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #271 from aspriddell/fix-logic
Browse files Browse the repository at this point in the history
use a cross-thread locking system
  • Loading branch information
aspriddell authored Dec 3, 2021
2 parents 51e39ec + eaacc8b commit 71e2e6f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions DragonFruit.Six.Api/Dragon6Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,13 @@
using DragonFruit.Six.Api.Enums;
using DragonFruit.Six.Api.Exceptions;
using DragonFruit.Six.Api.Utils;
using Nito.AsyncEx;

namespace DragonFruit.Six.Api
{
public abstract class Dragon6Client : ApiClient<ApiJsonSerializer>
{
private readonly object _lock = new();
private readonly AsyncLock _lock = new();
public static readonly CultureInfo Culture = new("en-US", false);

protected Dragon6Client(string userAgent = null, UbisoftService app = UbisoftService.RainbowSix)
Expand Down Expand Up @@ -72,13 +73,12 @@ protected virtual void ApplyToken(TokenBase token)

internal void ValidateToken()
{
lock (_lock)
using (_lock.Lock())
{
if (Token is null || Token.Expired)
if (Token?.Expired is not false)
{
// todo throw something if this is majorly expired or null
Token = GetToken();

ApplyToken(Token);
}
}
Expand Down

0 comments on commit 71e2e6f

Please sign in to comment.