From 4bbc2fc22dfe4fad93b852939256c1a1fa9f50f8 Mon Sep 17 00:00:00 2001 From: Angelo Breuer Date: Wed, 13 Jan 2021 16:24:12 +0100 Subject: [PATCH] Reset synchronization context on Application.Shutdown() - Fixes https://github.com/migueldeicaza/gui.cs/issues/1084 Reset synchronization context to allow the user to run async/await, as the main loop has been ended, the synchronization context from gui.cs does no longer process any callbacks. --- Terminal.Gui/Core/Application.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Terminal.Gui/Core/Application.cs b/Terminal.Gui/Core/Application.cs index 7bb1e9486..15143df5f 100644 --- a/Terminal.Gui/Core/Application.cs +++ b/Terminal.Gui/Core/Application.cs @@ -540,6 +540,12 @@ namespace Terminal.Gui { Driver?.End (); Driver = null; _initialized = false; + + // Reset synchronization context to allow the user to run async/await, + // as the main loop has been ended, the synchronization context from + // gui.cs does no longer process any callbacks. See #1084 for more details: + // (https://github.com/migueldeicaza/gui.cs/issues/1084). + SynchronizationContext.SetSynchronizationContext (syncContext: null); } static void Redraw (View view)