瀏覽代碼

Use Task.Delay instead of Thread.Sleep for resize polling. From #2731.

Tig Kindel 2 年之前
父節點
當前提交
645b93d648
共有 2 個文件被更改,包括 5 次插入3 次删除
  1. 3 2
      Terminal.Gui/ConsoleDrivers/NetDriver.cs
  2. 2 1
      Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

+ 3 - 2
Terminal.Gui/ConsoleDrivers/NetDriver.cs

@@ -223,8 +223,9 @@ namespace Terminal.Gui {
 		void WaitWinChange ()
 		{
 			while (true) {
-				// HACK: Sleep for 10ms to mitigate high CPU usage (see issue #1502). 10ms was tested to address the problem, but may not be correct.
-				Thread.Sleep (10);
+				// Wait for a while then check if screen has changed sizes
+				Task.Delay (500).Wait ();
+
 				if (stopTasks) {
 					return;
 				}

+ 2 - 1
Terminal.Gui/ConsoleDrivers/WindowsDriver.cs

@@ -1917,7 +1917,8 @@ namespace Terminal.Gui {
 		void WaitWinChange ()
 		{
 			while (true) {
-				Thread.Sleep (100);
+				// Wait for a while then check if screen has changed sizes
+				Task.Delay (500).Wait (); 
 				if (!consoleDriver.EnableConsoleScrolling) {
 					windowSize = winConsole.GetConsoleBufferWindow (out _);
 					//System.Diagnostics.Debug.WriteLine ($"{consoleDriver.EnableConsoleScrolling},{windowSize.Width},{windowSize.Height}");