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 f0e4a97
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 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,9 @@ 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);
#pragma warning disable CS1998
OnBotCommand(null!, EAccess.None, cmd, cmd.Split()).GetAwaiter().GetResult(); // TODO use async
#pragma warning restore CS1998
}
}
}
Expand Down

0 comments on commit f0e4a97

Please sign in to comment.