Browse Source

Moved CheckTimers to MainLoop - netdriver

Tigger Kindel 1 year ago
parent
commit
59d0613b14
1 changed files with 2 additions and 27 deletions
  1. 2 27
      Terminal.Gui/ConsoleDrivers/NetDriver.cs

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

@@ -1363,7 +1363,7 @@ internal class NetMainLoop : IMainLoopDriver {
 	{
 	{
 		_waitForProbe.Set ();
 		_waitForProbe.Set ();
 
 
-		if (CheckTimers (wait, out var waitTimeout)) {
+		if (_mainLoop.CheckTimers (wait, out var waitTimeout)) {
 			return true;
 			return true;
 		}
 		}
 
 
@@ -1378,7 +1378,7 @@ internal class NetMainLoop : IMainLoopDriver {
 		}
 		}
 
 
 		if (!_tokenSource.IsCancellationRequested) {
 		if (!_tokenSource.IsCancellationRequested) {
-			return _inputResult.Count > 0 || CheckTimers (wait, out _);
+			return _inputResult.Count > 0 || _mainLoop.CheckTimers (wait, out _);
 		}
 		}
 
 
 		_tokenSource.Dispose ();
 		_tokenSource.Dispose ();
@@ -1386,31 +1386,6 @@ internal class NetMainLoop : IMainLoopDriver {
 		return true;
 		return true;
 	}
 	}
 
 
-	bool CheckTimers (bool wait, out int waitTimeout)
-	{
-		var now = DateTime.UtcNow.Ticks;
-
-		if (_mainLoop._timeouts.Count > 0) {
-			waitTimeout = (int)((_mainLoop._timeouts.Keys [0] - now) / TimeSpan.TicksPerMillisecond);
-			if (waitTimeout < 0) {
-				return true;
-			}
-		} else {
-			waitTimeout = -1;
-		}
-
-		if (!wait) {
-			waitTimeout = 0;
-		}
-
-		int ic;
-		lock (_mainLoop._idleHandlers) {
-			ic = _mainLoop._idleHandlers.Count;
-		}
-
-		return ic > 0;
-	}
-
 	void IMainLoopDriver.Iteration ()
 	void IMainLoopDriver.Iteration ()
 	{
 	{
 		while (_inputResult.Count > 0) {
 		while (_inputResult.Count > 0) {