]> O.S.I.I.S - jp/crow.git/commitdiff
thread lock seems solved for fileviewer
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 21 Aug 2019 14:49:43 +0000 (16:49 +0200)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Wed, 21 Aug 2019 14:49:43 +0000 (16:49 +0200)
Crow/Crow.csproj
Crow/src/CrowThread.cs
Crow/src/GraphicObjects/TemplatedGroup.cs
Crow/src/GraphicObjects/Widget.cs

index 857a24e90291424432e3c969d22c0390a38ad2d3..e6ecc933d41c3b7e2f18bca2996fffb1b1d9c25b 100644 (file)
@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <Import Project="$(SolutionDir)netfx.props" />
   <PropertyGroup>
-    <TargetFrameworks>net461;net471;netstandard2.0</TargetFrameworks>
+    <TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
     <AssemblyName>Crow</AssemblyName>
     <Copyright></Copyright>
     <AssemblyVersion>0.8.3.2</AssemblyVersion>    
index 5c5ceef0c6b590b2e5a9d69f8b4115b9a52ed103..c0121bec0a6aa3afd2e5fb703502acec4c4a4ec7 100644 (file)
@@ -55,6 +55,8 @@ namespace Crow
                public void Cancel(){
                        if (thread.IsAlive & !cancelRequested){
                                cancelRequested = true;
+                               Thread.Sleep (1);
+                               thread.Abort ();
                                thread.Join ();
                        }
                        lock (Host.IFace.CrowThreads)
index cb57a72149fc2ad0d723effe07c85f0a70a076a6..3556eaf06373ce512e7403f9f3f69d0a7c775897 100644 (file)
@@ -29,6 +29,7 @@ using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Linq;
+using System.Threading;
 using Crow.IML;
 
 namespace Crow {
@@ -205,7 +206,7 @@ namespace Crow {
 
                                NotifyValueChanged ("Data", data);
 
-                               //lock (CurrentInterface.LayoutMutex)
+                               lock (IFace.LayoutMutex)
                                        ClearItems ();
 
                                if (data == null)
@@ -337,7 +338,14 @@ namespace Crow {
                /// Items loading thread
                /// </summary>
                void loading(){
-                       loadPage (data, items, dataTest);
+                       try {
+                               loadPage (data, items, dataTest);
+                       } catch (Exception ex) {
+                               if (Monitor.IsEntered (IFace.LayoutMutex))
+                                       Monitor.Exit (IFace.LayoutMutex);
+                               Console.WriteLine ("loading thread aborted");
+                       }
+
                }
 //                     //if (!ItemTemplates.ContainsKey ("default"))
 //                     //      ItemTemplates ["default"] = Interface.GetItemTemplate (ItemTemplate);
@@ -441,7 +449,7 @@ namespace Crow {
                                        iTemp = ItemTemplates ["default"];
                        }
 
-                       lock (IFace.LayoutMutex) {
+                       Monitor.Enter (IFace.LayoutMutex);
                                g = iTemp.CreateInstance();
                                #if DESIGN_MODE
                                g.design_isTGItem = true;
@@ -450,7 +458,7 @@ namespace Crow {
 //                             if (isPaged)
                                g.LogicalParent = this;
                                g.MouseClick += itemClick;
-                       }
+                       Monitor.Exit (IFace.LayoutMutex);
 
                        if (iTemp.Expand != null && g is Expandable) {
                                Expandable e = g as Expandable;
index 663cb26e085149bd950a1467cedc78be3532fc2a..d85ddfaac4f09b570a14f9ee3aed4db54159b156 100644 (file)
@@ -1007,7 +1007,7 @@ namespace Crow
                                #if DEBUG_LOG
                                DbgEvent dbgEvt = DebugLog.AddEvent(DbgEvtType.GOLockLayouting, this);
                                #endif
-                               lock (IFace.LayoutMutex) {
+                               lock (IFace.UpdateMutex) {
                                        OnDataSourceChanged (this, dse);
                                        NotifyValueChanged ("DataSource", DataSource);
                                }