mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2025-12-28 08:47:59 +01:00
[Re]move unwanted allocation (new CancellationTokenSource()) in WindowsDriver.EventsPending to only when needed (#274)
This commit is contained in:
committed by
Miguel de Icaza
parent
c832688112
commit
f0a079b242
@@ -503,8 +503,7 @@ namespace Terminal.Gui {
|
||||
|
||||
result = null;
|
||||
waitForProbe.Set();
|
||||
tokenSource.Dispose();
|
||||
tokenSource = new CancellationTokenSource();
|
||||
|
||||
try {
|
||||
eventReady.Wait(waitTimeout, tokenSource.Token);
|
||||
} catch (OperationCanceledException) {
|
||||
@@ -513,7 +512,13 @@ namespace Terminal.Gui {
|
||||
eventReady.Reset();
|
||||
}
|
||||
Debug.WriteLine("Events ready");
|
||||
return result != null || tokenSource.IsCancellationRequested;
|
||||
|
||||
if (!tokenSource.IsCancellationRequested)
|
||||
return result != null;
|
||||
|
||||
tokenSource.Dispose();
|
||||
tokenSource = new CancellationTokenSource();
|
||||
return true;
|
||||
}
|
||||
|
||||
Action<KeyEvent> keyHandler;
|
||||
|
||||
Reference in New Issue
Block a user