From 06e7cf346958beada293b1f60773aee3236ecd79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=85=AC=E5=BD=A6=E8=B5=A4=E5=B1=8B=E5=85=88?= Date: Wed, 5 Jun 2024 18:26:43 +0900 Subject: [PATCH] Don't treat timeouts as crashes --- Amethyst/Amethyst.csproj | 4 ++-- Amethyst/Classes/Main.cs | 7 +++++-- Amethyst/Package.appxmanifest | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Amethyst/Amethyst.csproj b/Amethyst/Amethyst.csproj index 954fc6b..8c19558 100644 --- a/Amethyst/Amethyst.csproj +++ b/Amethyst/Amethyst.csproj @@ -28,8 +28,8 @@ Amethyst (Desktop) App k2vr.tech - 1.2.13.0 - 1.2.13.0 + 1.2.14.0 + 1.2.14.0 https://github.com/KinectToVR/Amethyst true diff --git a/Amethyst/Classes/Main.cs b/Amethyst/Classes/Main.cs index ca514c6..139eef4 100644 --- a/Amethyst/Classes/Main.cs +++ b/Amethyst/Classes/Main.cs @@ -590,7 +590,7 @@ public static async void MainLoop() { serverLoops = 0; // Reset the counter for the next 10'000 service loops var elapsedTicks = loopStopWatch.ElapsedTicks; // Cache the elapsed time - await Task.Delay(TimeSpan.FromTicks(diffTicks)); + await Task.Delay(TimeSpan.FromTicks(diffTicks), cancellationToken.Token); Logger.Info($"10000 loops have passed: this loop took {elapsedTicks} [ticks], " + $"the loop's time after time correction (sleep) is: {loopStopWatch.ElapsedTicks} [ticks]"); @@ -598,7 +598,7 @@ public static async void MainLoop() else { serverLoops++; // Else increase passed loops counter and wait - await Task.Delay(TimeSpan.FromTicks(diffTicks)); + await Task.Delay(TimeSpan.FromTicks(diffTicks), cancellationToken.Token); } #pragma warning disable CA1806 // Do not ignore method results @@ -623,6 +623,9 @@ public static async void MainLoop() serverTries++; // One more? switch (serverTries) { + case > 0 when e is TaskCanceledException: + break; // It's probably the token timeout, just don't care... + case > 3 and <= 7: // We've crashed the third time now. Something's off.. really... Logger.Fatal(new AggregateException( diff --git a/Amethyst/Package.appxmanifest b/Amethyst/Package.appxmanifest index f81dbea..a2c479b 100644 --- a/Amethyst/Package.appxmanifest +++ b/Amethyst/Package.appxmanifest @@ -11,7 +11,7 @@ + Version="1.2.14.0" /> Amethyst - Open Source Body Tracking