diff --git a/DragonFruit.Six.Api/Dragon6Client.cs b/DragonFruit.Six.Api/Dragon6Client.cs index 9e3faab3..7a57f5e1 100644 --- a/DragonFruit.Six.Api/Dragon6Client.cs +++ b/DragonFruit.Six.Api/Dragon6Client.cs @@ -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 { - 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) @@ -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); } }