Skip to content

Commit

Permalink
Use ThreadLocal instead of AsyncLocal + remove async for quick & dirt…
Browse files Browse the repository at this point in the history
…y fix
  • Loading branch information
maxisoft committed Dec 3, 2024
1 parent a5dd91b commit dc560be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ASFFreeGames/ASFFreeGamesPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ internal static PluginContext Context {
}

// ReSharper disable once InconsistentNaming
private static readonly AsyncLocal<PluginContext> _context = new();
private static readonly ThreadLocal<PluginContext> _context = new();
private static CancellationToken CancellationToken => Context.CancellationToken;

public string Name => StaticName;
Expand Down Expand Up @@ -141,7 +141,7 @@ public async void CollectGamesOnClock(object? source) {

if (!cts.IsCancellationRequested) {
string cmd = $"FREEGAMES {FreeGamesCommand.CollectInternalCommandString} " + string.Join(' ', reorderedBots.Select(static bot => bot.BotName));
await OnBotCommand(null!, EAccess.None, cmd, cmd.Split()).ConfigureAwait(false);
OnBotCommand(null!, EAccess.None, cmd, cmd.Split()).GetAwaiter().GetResult(); // TODO use async
}
}
}
Expand Down

0 comments on commit dc560be

Please sign in to comment.