From 473bba87f691879fc0677b993e677f3e084f83ba Mon Sep 17 00:00:00 2001 From: Patrick Simpson Date: Thu, 9 Feb 2017 10:14:39 +0100 Subject: [PATCH] Small fixes, debug tweaks --- .../Features/DebugSupport/DebugDialog.cs | 8 ++------ .../Features/DebugSupport/FeatureDebugSupport.cs | 6 ++++-- .../AcaciaZPushPlugin/Utils/MailEvents.cs | 6 +----- src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/Util.cs | 9 +++++++++ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/DebugSupport/DebugDialog.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/DebugSupport/DebugDialog.cs index acd8d91..97d58be 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/DebugSupport/DebugDialog.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/DebugSupport/DebugDialog.cs @@ -163,12 +163,8 @@ namespace Acacia.Features.DebugSupport } private void GarbageCollect() - { - GC.Collect(); - GC.WaitForPendingFinalizers(); - GC.Collect(); - GC.WaitForPendingFinalizers(); - + { + Util.GarbageCollect(); UpdateFields(); } diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/DebugSupport/FeatureDebugSupport.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/DebugSupport/FeatureDebugSupport.cs index 12e43d5..53d5855 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/DebugSupport/FeatureDebugSupport.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Features/DebugSupport/FeatureDebugSupport.cs @@ -48,7 +48,7 @@ namespace Acacia.Features.DebugSupport public override void AfterStartup() { - ShowAbout(); + //ShowAbout(); } #region About dialog @@ -79,7 +79,9 @@ namespace Acacia.Features.DebugSupport public void ShowSettings() { - new SettingsDialog().ShowDialog(); + //new SettingsDialog().ShowDialog(); + ThisAddIn.Instance.GetFeature()?.FullResync(); + Tasks.Task(this, "GC", () => Util.GarbageCollect()); } public override FeatureSettings GetSettings() diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/MailEvents.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/MailEvents.cs index a0dd6d7..2978dae 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/MailEvents.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/MailEvents.cs @@ -208,8 +208,6 @@ namespace Acacia.Utils #region Implementation - private readonly HashSet _keepAlives = new HashSet(); - public MailEvents(IAddIn app) { app.ItemLoad += OnItemLoad; @@ -221,7 +219,7 @@ namespace Acacia.Utils NSOutlook.ItemEvents_10_Event hasEvents = item as NSOutlook.ItemEvents_10_Event; if (hasEvents != null) { - _keepAlives.Add(new MailEventHooker(item, hasEvents, this)); + new MailEventHooker(item, hasEvents, this); } else ComRelease.Release(item); } @@ -248,8 +246,6 @@ namespace Acacia.Utils { Logger.Instance.Debug(this, "DoRelease: {0}", _id); - _events._keepAlives.Remove(this); - ComRelease.Release(_item); _item = null; ComRelease.Release(_itemEvents); diff --git a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/Util.cs b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/Util.cs index 0803c1a..df4050e 100644 --- a/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/Util.cs +++ b/src/AcaciaZPushPlugin/AcaciaZPushPlugin/Utils/Util.cs @@ -79,5 +79,14 @@ namespace Acacia.Utils } ComRelease.Release(source); } + + public static void GarbageCollect() + { + for (int i = 0; i < 4; ++i) + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + } + } } }