Skip to content

Commit

Permalink
Dispose Containers (except for Autocad) (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock authored Sep 18, 2024
1 parent b52d66c commit 1dbb2b6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ protected override bool CanUnload()
//TODO - add your business logic
//return false to ~cancel~ Application close
_disposableLogger?.Dispose();
Container.Dispose();
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public Result OnShutdown(UIControlledApplication application)
// need to look for commonality
_revitPlugin?.Shutdown();
_disposableLogger?.Dispose();
_container?.Dispose();
}
catch (Exception e) when (!e.IsFatal())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ protected override void OnShutdown()
{
_rhinoPlugin?.Shutdown();
_disposableLogger?.Dispose();
Container?.Dispose();
base.OnShutdown();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Speckle.Connectors.DUI.WebView;

public sealed partial class DUI3ControlWebView : UserControl, IBrowserScriptExecutor
public sealed partial class DUI3ControlWebView : UserControl, IBrowserScriptExecutor, IDisposable
{
private readonly IEnumerable<Lazy<IBinding>> _bindings;

Expand Down Expand Up @@ -58,4 +58,7 @@ private void SetupBinding(IBinding binding)
}

public void ShowDevTools() => Browser.CoreWebView2.OpenDevToolsWindow();

//https://github.com/MicrosoftEdge/WebView2Feedback/issues/2161
public void Dispose() => Browser.Dispatcher.Invoke(() => Browser.Dispose(), DispatcherPriority.Send);
}
16 changes: 4 additions & 12 deletions Sdk/Speckle.Autofac/DependencyInjection/SpeckleContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,10 @@

namespace Speckle.Autofac.DependencyInjection;

public class SpeckleContainer
public sealed class SpeckleContainer(IContainer container) : IDisposable
{
private readonly IContainer _container;

public SpeckleContainer(IContainer container)
{
_container = container;
}

public T Resolve<T>()
where T : class
{
return _container.Resolve<T>();
}
where T : class => container.Resolve<T>();

public void Dispose() => container.Dispose();
}

0 comments on commit 1dbb2b6

Please sign in to comment.