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 2e5a536
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 disable CS1998

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / publish (ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / publish (macos-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, macos-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, macos-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, macos-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, macos-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, ubuntu-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, ubuntu-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, ubuntu-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, ubuntu-latest)

Unrecognized #pragma directive

Check warning on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, windows-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / integration (Release, latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / integration (Release, latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / integration (Release, latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / integration (Release, latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, macos-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, macos-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, macos-latest)

Unrecognized #pragma directive

Check failure on line 144 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, macos-latest)

Unrecognized #pragma directive
OnBotCommand(null!, EAccess.None, cmd, cmd.Split()).GetAwaiter().GetResult(); // TODO use async
#pragma restore CS1998

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / publish (ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / publish (macos-latest)

Unrecognized #pragma directive

Check warning on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, macos-latest)

Unrecognized #pragma directive

Check warning on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, macos-latest)

Unrecognized #pragma directive

Check warning on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, macos-latest)

Unrecognized #pragma directive

Check warning on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, ubuntu-latest)

Unrecognized #pragma directive

Check warning on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, ubuntu-latest)

Unrecognized #pragma directive

Check warning on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, ubuntu-latest)

Unrecognized #pragma directive

Check warning on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Debug, windows-latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / integration (Release, latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / integration (Release, latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / integration (Release, latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, ubuntu-latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, macos-latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, macos-latest)

Unrecognized #pragma directive

Check failure on line 146 in ASFFreeGames/ASFFreeGamesPlugin.cs

View workflow job for this annotation

GitHub Actions / main (Release, macos-latest)

Unrecognized #pragma directive
}
}
}
Expand Down

0 comments on commit 2e5a536

Please sign in to comment.