diff options
| author | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-19 16:38:31 -0400 |
|---|---|---|
| committer | LukePulverenti Luke Pulverenti luke pulverenti <LukePulverenti Luke Pulverenti luke.pulverenti@gmail.com> | 2012-08-19 16:38:31 -0400 |
| commit | 937d27ae9d6aa571ab9327f138bfba1b84c158db (patch) | |
| tree | 94be178039621ea6d6235967414b0849912af4ed /MediaBrowser.Common/Kernel/BaseKernel.cs | |
| parent | 64887fa74347260d44a8cb5cc7058cd22b08c1c5 (diff) | |
One async call leads to another, and another, all the way up the call stack...
Diffstat (limited to 'MediaBrowser.Common/Kernel/BaseKernel.cs')
| -rw-r--r-- | MediaBrowser.Common/Kernel/BaseKernel.cs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/MediaBrowser.Common/Kernel/BaseKernel.cs b/MediaBrowser.Common/Kernel/BaseKernel.cs index 7b6f6844c..5b2f97ced 100644 --- a/MediaBrowser.Common/Kernel/BaseKernel.cs +++ b/MediaBrowser.Common/Kernel/BaseKernel.cs @@ -2,17 +2,16 @@ using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
-using System.Configuration;
using System.IO;
using System.Linq;
using System.Reflection;
+using System.Threading.Tasks;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Logging;
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Common.Serialization;
using MediaBrowser.Model.Progress;
-using System.Threading.Tasks;
namespace MediaBrowser.Common.Kernel
{
@@ -93,6 +92,8 @@ namespace MediaBrowser.Common.Kernel /// </summary>
protected void ReloadComposableParts()
{
+ DisposeComposableParts();
+
// Gets all plugin assemblies by first reading all bytes of the .dll and calling Assembly.Load against that
// This will prevent the .dll file from getting locked, and allow us to replace it when needed
IEnumerable<Assembly> pluginAssemblies = Directory.GetFiles(ApplicationPaths.PluginsPath, "*.dll", SearchOption.AllDirectories).Select(f => Assembly.Load(File.ReadAllBytes((f))));
@@ -203,11 +204,34 @@ namespace MediaBrowser.Common.Kernel /// </summary>
public virtual void Dispose()
{
+ DisposeComposableParts();
DisposeHttpServer();
DisposeLogger();
}
/// <summary>
+ /// Disposes all objects gathered through MEF composable parts
+ /// </summary>
+ protected virtual void DisposeComposableParts()
+ {
+ DisposePlugins();
+ }
+
+ /// <summary>
+ /// Disposes all plugins
+ /// </summary>
+ private void DisposePlugins()
+ {
+ if (Plugins != null)
+ {
+ foreach (BasePlugin plugin in Plugins)
+ {
+ plugin.Dispose();
+ }
+ }
+ }
+
+ /// <summary>
/// Disposes the current HttpServer
/// </summary>
private void DisposeHttpServer()
|
