Skip to content

Commit c42f356

Browse files
committed
Use ThreadLocal instead of AsyncLocal + remove async for quick & dirty fix
1 parent a5dd91b commit c42f356

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ASFFreeGames/ASFFreeGamesPlugin.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ internal static PluginContext Context {
4040
}
4141

4242
// ReSharper disable once InconsistentNaming
43-
private static readonly AsyncLocal<PluginContext> _context = new();
43+
private static readonly ThreadLocal<PluginContext> _context = new();
4444
private static CancellationToken CancellationToken => Context.CancellationToken;
4545

4646
public string Name => StaticName;
@@ -107,7 +107,7 @@ public async Task OnASFInit(IReadOnlyDictionary<string, JsonElement>? additional
107107

108108
public Task OnUpdateProceeding(Version currentVersion, Version newVersion) => Task.CompletedTask;
109109

110-
public async void CollectGamesOnClock(object? source) {
110+
public void CollectGamesOnClock(object? source) {
111111
CollectIntervalManager.RandomlyChangeCollectInterval(source);
112112

113113
if (!Context.Valid || ((Bots.Count > 0) && (Context.Bots.Count != Bots.Count))) {
@@ -141,7 +141,9 @@ public async void CollectGamesOnClock(object? source) {
141141

142142
if (!cts.IsCancellationRequested) {
143143
string cmd = $"FREEGAMES {FreeGamesCommand.CollectInternalCommandString} " + string.Join(' ', reorderedBots.Select(static bot => bot.BotName));
144-
await OnBotCommand(null!, EAccess.None, cmd, cmd.Split()).ConfigureAwait(false);
144+
#pragma warning disable CS1998
145+
OnBotCommand(null!, EAccess.None, cmd, cmd.Split()).GetAwaiter().GetResult(); // TODO use async
146+
#pragma warning restore CS1998
145147
}
146148
}
147149
}

0 commit comments

Comments
 (0)