mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-26 15:57:56 +01:00
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.
This commit is contained in:
committed by
Miguel de Icaza
parent
a20d244d59
commit
9a70c1319b
@@ -504,7 +504,8 @@ namespace Terminal.Gui {
|
||||
waitForProbe.Set();
|
||||
|
||||
try {
|
||||
eventReady.Wait(waitTimeout, tokenSource.Token);
|
||||
if(!tokenSource.IsCancellationRequested)
|
||||
eventReady.Wait(waitTimeout, tokenSource.Token);
|
||||
} catch (OperationCanceledException) {
|
||||
return true;
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user