mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Fix AutoRelog retry accounting
This commit is contained in:
parent
f39fe2d067
commit
47de24cf1d
2 changed files with 113 additions and 21 deletions
|
|
@ -899,12 +899,25 @@ namespace MinecraftClient
|
|||
/// <param name="delaySeconds">Optional delay, in seconds, before restarting</param>
|
||||
/// <param name="keepAccountAndServerSettings">Optional, keep account and server settings</param>
|
||||
public static void Restart(int delaySeconds = 0, bool keepAccountAndServerSettings = false)
|
||||
{
|
||||
TryRestart(delaySeconds, keepAccountAndServerSettings);
|
||||
}
|
||||
|
||||
internal static bool HasRestartPendingForAnotherThread
|
||||
{
|
||||
get
|
||||
{
|
||||
lock (_restartLock)
|
||||
return HasRestartPendingForAnotherThreadNoLock();
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool TryRestart(int delaySeconds = 0, bool keepAccountAndServerSettings = false)
|
||||
{
|
||||
lock (_restartLock)
|
||||
{
|
||||
if (_restartThread is not null && _restartThread.IsAlive
|
||||
&& _restartThread != Thread.CurrentThread)
|
||||
return;
|
||||
if (HasRestartPendingForAnotherThreadNoLock())
|
||||
return false;
|
||||
|
||||
ConsoleIO.Backend?.StopReadThread();
|
||||
var thread = new Thread(new ThreadStart(delegate
|
||||
|
|
@ -938,9 +951,17 @@ namespace MinecraftClient
|
|||
}));
|
||||
_restartThread = thread;
|
||||
thread.Start();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool HasRestartPendingForAnotherThreadNoLock()
|
||||
{
|
||||
return _restartThread is not null
|
||||
&& _restartThread.IsAlive
|
||||
&& _restartThread != Thread.CurrentThread;
|
||||
}
|
||||
|
||||
public static void DoExit(int exitcode = 0)
|
||||
{
|
||||
WriteBackSettings();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue