From 1d9aa6aa61da3dd5f1a1a488018ceb8b5a88f2af Mon Sep 17 00:00:00 2001 From: j-p Date: Mon, 28 Aug 2017 05:12:19 +0200 Subject: full IDisposable implementation (#34) * full implementation of IDisposable, not stable, lock and still leaking * override dispose in popper to handle _content not yet in graphic tree (when never shown), test focusedWidget when disposing * prevent canceling thread multiple times causing a deadlock * test parent type when trying to close window --- src/CrowThread.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/CrowThread.cs') diff --git a/src/CrowThread.cs b/src/CrowThread.cs index fbcdc956..823fe1a6 100644 --- a/src/CrowThread.cs +++ b/src/CrowThread.cs @@ -33,7 +33,7 @@ namespace Crow /// Thread monitored by current interface with Finished event when state==Stopped /// public class CrowThread { - public bool cancel = false; + public bool cancelRequested = false; Thread thread; public event EventHandler Finished; public GraphicObject Host; @@ -53,11 +53,9 @@ namespace Crow } public void Start() { thread.Start();} public void Cancel(){ - if (thread.IsAlive){ - cancel = true; - //cancelLoading = true; + if (thread.IsAlive & !cancelRequested){ + cancelRequested = true; thread.Join (); - //cancelLoading = false; } lock (Host.currentInterface.CrowThreads) Host.currentInterface.CrowThreads.Remove (this); -- cgit v1.3.1-4-g156e