From 3b5c1100c390ff15e2d7757ffe21ac1a759187de Mon Sep 17 00:00:00 2001 From: BDisp Date: Fri, 31 May 2024 23:07:55 +0100 Subject: [PATCH] Revert "Improving performance on CheckWindowSizeChange." This reverts commit 8c500fcbb72e84cad0a13c04e16b0f1826f6e83b. --- Terminal.Gui/ConsoleDrivers/NetDriver.cs | 50 ++++++++++++------------ 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/Terminal.Gui/ConsoleDrivers/NetDriver.cs b/Terminal.Gui/ConsoleDrivers/NetDriver.cs index b7602fcb4..b6b1d6175 100644 --- a/Terminal.Gui/ConsoleDrivers/NetDriver.cs +++ b/Terminal.Gui/ConsoleDrivers/NetDriver.cs @@ -328,36 +328,14 @@ internal class NetEvents : IDisposable } } - private async Task CheckWindowSizeChange () + private void CheckWindowSizeChange () { - while (true) - { - if (_inputReadyCancellationTokenSource.IsCancellationRequested) - { - return; - } - - try - { - _winChange.Wait (_inputReadyCancellationTokenSource.Token); - _winChange.Reset (); - - await RequestWindowSize (_inputReadyCancellationTokenSource.Token); - } - catch (OperationCanceledException) - { - return; - } - - _inputReady.Set (); - } - - async Task RequestWindowSize (CancellationToken cancellationToken) + void RequestWindowSize (CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested) { // Wait for a while then check if screen has changed sizes - await Task.Delay (500, cancellationToken); + Task.Delay (500, cancellationToken); int buffHeight, buffWidth; @@ -385,6 +363,28 @@ internal class NetEvents : IDisposable cancellationToken.ThrowIfCancellationRequested (); } + + while (true) + { + if (_inputReadyCancellationTokenSource.IsCancellationRequested) + { + return; + } + + try + { + _winChange.Wait (_inputReadyCancellationTokenSource.Token); + _winChange.Reset (); + + RequestWindowSize (_inputReadyCancellationTokenSource.Token); + } + catch (OperationCanceledException) + { + return; + } + + _inputReady.Set (); + } } /// Enqueue a window size event if the window size has changed.