Pārlūkot izejas kodu

Avoid throwing when the tokenSource is cancelled (#266)

When invoking an action in the main loop, the token will be cancelled (see
`MainLoop.Invoke` and `WindowsDriver.Wakeup`). At this point when the
EventsPending is running we must avoid throwing by waiting using a cancelled token:

`eventReady.Wait(waitTimeout, tokenSource.Token)`

And make sure we reach the disposal of the token source. Otherwise we keep throwing
over and over and cause a severe performance problem for the running app.
Daniel Cazzulino 5 gadi atpakaļ
vecāks
revīzija
9a70c1319b
1 mainītis faili ar 2 papildinājumiem un 1 dzēšanām
  1. 2 1
      Terminal.Gui/Drivers/WindowsDriver.cs

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

@@ -504,7 +504,8 @@ namespace Terminal.Gui {
 			waitForProbe.Set();
 			waitForProbe.Set();
 
 
 			try {
 			try {
-				eventReady.Wait(waitTimeout, tokenSource.Token);
+				if(!tokenSource.IsCancellationRequested)
+					eventReady.Wait(waitTimeout, tokenSource.Token);
 			} catch (OperationCanceledException) {
 			} catch (OperationCanceledException) {
 				return true;
 				return true;
 			} finally {
 			} finally {