From: Lars Op den Kamp Date: Fri, 13 Dec 2013 10:51:41 +0000 (+0100) Subject: still locking up when disposing, because the log callback is trying to write to the... X-Git-Tag: upstream/2.2.0~1^2~3^2~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=48b0a2601fbd52ee98b65d23970f22256aade17d;p=deb_libcec.git still locking up when disposing, because the log callback is trying to write to the disposing ui. disconnect from a background thread instead when disposing --- diff --git a/src/LibCecTray/ui/CECTray.cs b/src/LibCecTray/ui/CECTray.cs index 197ce32..021eaa3 100644 --- a/src/LibCecTray/ui/CECTray.cs +++ b/src/LibCecTray/ui/CECTray.cs @@ -41,6 +41,7 @@ using LibCECTray.settings; using Microsoft.Win32; using System.Security.Permissions; using System.Runtime.InteropServices; +using System.Threading; namespace LibCECTray.ui { @@ -57,6 +58,21 @@ namespace LibCECTray.ui XBMC } + class AsyncDisconnect + { + public AsyncDisconnect(CECController controller) + { + _controller = controller; + } + + public void Process() + { + _controller.Close(); + } + + private CECController _controller; + } + /// /// Main LibCecTray GUI /// @@ -174,11 +190,11 @@ namespace LibCECTray.ui protected override void Dispose(bool disposing) { Hide(); - SuppressLogUpdates = true; if (disposing) { Controller.CECActions.SuppressUpdates = true; - Controller.Close(); + AsyncDisconnect dc = new AsyncDisconnect(Controller); + (new Thread(dc.Process)).Start(); } if (disposing && (components != null)) { @@ -312,9 +328,6 @@ namespace LibCECTray.ui delegate void UpdateLogCallback(); private void UpdateLog() { - if (SuppressLogUpdates) - return; - if (tbLog.InvokeRequired) { UpdateLogCallback d = UpdateLog; @@ -572,7 +585,6 @@ namespace LibCECTray.ui #endregion #region Class members - private bool SuppressLogUpdates = false; private ConfigTab _selectedTab = ConfigTab.Configuration; private string _log = string.Empty; private CECController _controller;