From 064b17dd0c4df878c9a5ff9ed361318969515302 Mon Sep 17 00:00:00 2001 From: RandomGuy155 Date: Sat, 8 Aug 2026 03:01:32 -0400 Subject: [PATCH] Fix double detach from controller `Stop()` called `HardStop()` which was then called again by `MainLoop` once the token was cancelled. Removed from `Stop()`. Just let the main loop handle stopping upon receiving the cancellation token. Moved `IsPaused` and `IsStopping` resets to the existing continuation in `Start()` --- SysBot.Base/Control/BotSource.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/SysBot.Base/Control/BotSource.cs b/SysBot.Base/Control/BotSource.cs index b0299dd52..a35cb95a0 100644 --- a/SysBot.Base/Control/BotSource.cs +++ b/SysBot.Base/Control/BotSource.cs @@ -22,10 +22,6 @@ public void Stop() IsStopping = true; Source.Cancel(); Source = new CancellationTokenSource(); - - Task.Run(async () => await Bot.HardStop() - .ContinueWith(ReportFailure, TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously) - .ContinueWith(_ => IsPaused = IsRunning = IsStopping = false)); } public void Pause() @@ -50,7 +46,7 @@ public void Start() IsRunning = true; Task.Run(async () => await Bot.RunAsync(Source.Token) .ContinueWith(ReportFailure, TaskContinuationOptions.OnlyOnFaulted | TaskContinuationOptions.ExecuteSynchronously) - .ContinueWith(_ => IsRunning = false)); + .ContinueWith(_ => IsPaused = IsRunning = IsStopping = false)); } public void Restart()