fix(autotranslate): mark warmup thread as IsBackground

F9.2: PreloadCache spawned a new Thread without IsBackground, which kept
the plugin unload blocked until the warmup finished (typically
100-300 ms). Setting IsBackground=true plus a named thread matches the
pattern already used in MessageManager (F6.1) and Plugin.RetentionSweep
(F9.3) since v1.4.0.
This commit is contained in:
2026-05-12 09:33:57 +02:00
parent 5ca3b73b7f
commit 83064cd40b
+9 -3
View File
@@ -54,15 +54,21 @@ internal static class AutoTranslate
}
// Warms the auto-translate cache on a background thread so the first
// message send doesn't hitch the main thread.
// message send doesn't hitch the main thread. IsBackground keeps plugin
// unload non-blocking even if the warmup is still in flight.
internal static void PreloadCache()
{
new Thread(() =>
var thread = new Thread(() =>
{
var sw = Stopwatch.StartNew();
AllEntries();
Plugin.Log.Debug($"Warming up auto-translate took {sw.ElapsedMilliseconds}ms");
}).Start();
})
{
IsBackground = true,
Name = "HellionChat-AutoTranslate-Warmup",
};
thread.Start();
}
private static List<AutoTranslateEntry> AllEntries()