Skip to content

Commit

Permalink
feat: Manually dispose of ServiceLocator (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaspermarstal authored Sep 24, 2024
1 parent 21b8024 commit 65744e7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Cellm/AddIn/Cellm.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using ExcelDna.Integration;
using Cellm.Services;
using ExcelDna.Integration;

namespace Cellm.AddIn;

Expand All @@ -16,6 +17,7 @@ public void AutoOpen()

public void AutoClose()
{
ServiceLocator.Dispose();
SentrySdk.Flush();
}
}
8 changes: 8 additions & 0 deletions src/Cellm/Services/ServiceLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,12 @@ private static IServiceCollection ConfigureServices(IServiceCollection services)

return services;
}

public static void Dispose()
{
if (_serviceProvider.IsValueCreated)
{
(_serviceProvider.Value as IDisposable)?.Dispose();
}
}
}

0 comments on commit 65744e7

Please sign in to comment.