Small fixes, debug tweaks

This commit is contained in:
Patrick Simpson 2017-02-09 10:14:39 +01:00
parent 9f237b76e0
commit 473bba87f6
4 changed files with 16 additions and 13 deletions

View File

@ -164,11 +164,7 @@ namespace Acacia.Features.DebugSupport
private void GarbageCollect() private void GarbageCollect()
{ {
GC.Collect(); Util.GarbageCollect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();
UpdateFields(); UpdateFields();
} }

View File

@ -48,7 +48,7 @@ namespace Acacia.Features.DebugSupport
public override void AfterStartup() public override void AfterStartup()
{ {
ShowAbout(); //ShowAbout();
} }
#region About dialog #region About dialog
@ -79,7 +79,9 @@ namespace Acacia.Features.DebugSupport
public void ShowSettings() public void ShowSettings()
{ {
new SettingsDialog().ShowDialog(); //new SettingsDialog().ShowDialog();
ThisAddIn.Instance.GetFeature<GAB.FeatureGAB>()?.FullResync();
Tasks.Task(this, "GC", () => Util.GarbageCollect());
} }
public override FeatureSettings GetSettings() public override FeatureSettings GetSettings()

View File

@ -208,8 +208,6 @@ namespace Acacia.Utils
#region Implementation #region Implementation
private readonly HashSet<MailEventHooker> _keepAlives = new HashSet<MailEventHooker>();
public MailEvents(IAddIn app) public MailEvents(IAddIn app)
{ {
app.ItemLoad += OnItemLoad; app.ItemLoad += OnItemLoad;
@ -221,7 +219,7 @@ namespace Acacia.Utils
NSOutlook.ItemEvents_10_Event hasEvents = item as NSOutlook.ItemEvents_10_Event; NSOutlook.ItemEvents_10_Event hasEvents = item as NSOutlook.ItemEvents_10_Event;
if (hasEvents != null) if (hasEvents != null)
{ {
_keepAlives.Add(new MailEventHooker(item, hasEvents, this)); new MailEventHooker(item, hasEvents, this);
} }
else ComRelease.Release(item); else ComRelease.Release(item);
} }
@ -248,8 +246,6 @@ namespace Acacia.Utils
{ {
Logger.Instance.Debug(this, "DoRelease: {0}", _id); Logger.Instance.Debug(this, "DoRelease: {0}", _id);
_events._keepAlives.Remove(this);
ComRelease.Release(_item); ComRelease.Release(_item);
_item = null; _item = null;
ComRelease.Release(_itemEvents); ComRelease.Release(_itemEvents);

View File

@ -79,5 +79,14 @@ namespace Acacia.Utils
} }
ComRelease.Release(source); ComRelease.Release(source);
} }
public static void GarbageCollect()
{
for (int i = 0; i < 4; ++i)
{
GC.Collect();
GC.WaitForPendingFinalizers();
}
}
} }
} }