diff options
author | Jesse Plamondon-Willard <Pathoschild@users.noreply.github.com> | 2020-09-22 18:24:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 18:24:02 -0400 |
commit | 64d4e1d3da3585c5d1e0cbb3bd924f3734d6e182 (patch) | |
tree | b1b934166e857dc789e7904c4d1f46f1b86ab8a9 /src | |
parent | e0b3f97f9e7fee838d53f020ec4ddc29a2d194e1 (diff) | |
parent | d5c98bf2df2baff4ed048c35d903424b8e1ce2e2 (diff) | |
download | SMAPI-64d4e1d3da3585c5d1e0cbb3bd924f3734d6e182.tar.gz SMAPI-64d4e1d3da3585c5d1e0cbb3bd924f3734d6e182.tar.bz2 SMAPI-64d4e1d3da3585c5d1e0cbb3bd924f3734d6e182.zip |
Merge pull request #734 from millerscout/feature/performanceTuning
Improve performance of exit handler
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI/Framework/Logging/LogManager.cs | 14 | ||||
-rw-r--r-- | src/SMAPI/Framework/SCore.cs | 7 |
2 files changed, 11 insertions, 10 deletions
diff --git a/src/SMAPI/Framework/Logging/LogManager.cs b/src/SMAPI/Framework/Logging/LogManager.cs index 094dd749..d83a5c0b 100644 --- a/src/SMAPI/Framework/Logging/LogManager.cs +++ b/src/SMAPI/Framework/Logging/LogManager.cs @@ -138,15 +138,15 @@ namespace StardewModdingAPI.Framework.Logging Thread inputThread = new Thread(() => { while (true) - { + { // get input - string input = Console.ReadLine(); - if (string.IsNullOrWhiteSpace(input)) - continue; + string input = Console.ReadLine(); + if (string.IsNullOrWhiteSpace(input)) + continue; - // handle command - this.Monitor.LogUserInput(input); - handleInput(input); + // handle command + this.Monitor.LogUserInput(input); + handleInput(input); } }); inputThread.Start(); diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index e64c2801..e2a9463b 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -278,15 +278,16 @@ namespace StardewModdingAPI.Framework ); // add exit handler - new Thread(() => + this.CancellationToken.Token.Register(() => { - this.CancellationToken.Token.WaitHandle.WaitOne(); if (this.IsGameRunning) { + this.inputThread.Abort(); this.LogManager.WriteCrashLog(); this.Game.Exit(); } - }).Start(); + }); + // set window titles this.SetWindowTitles( |