Changeset 16909
- Timestamp:
- 05/07/19 15:02:47 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.PluginInfrastructure/3.3/SandboxApplicationManager.cs
r16565 r16909 71 71 loadedAssemblies = new Dictionary<string, Assembly>(); 72 72 loadedPlugins = new List<IPlugin>(); 73 74 AppDomain.CurrentDomain.DomainUnload += CurrentDomain_DomainUnload; 75 } 76 77 /// <summary> 78 /// The sandbox application manager can also be used to load plugins even when no actual application is executed. 79 /// In such cases, plugins that have been loaded also have to be unloaded again before the application domain is unloaded. 80 /// </summary> 81 private void CurrentDomain_DomainUnload(object sender, EventArgs e) { 82 UnloadPlugins(); 73 83 } 74 84 … … 111 121 112 122 /// <summary> 123 /// Unloads the <paramref name="plugins"/> that were loaded into this application domain. 124 /// </summary> 125 private void UnloadPlugins() { 126 // unload plugins in reverse order 127 foreach (var plugin in loadedPlugins.Reverse<IPlugin>()) { 128 plugin.OnUnload(); 129 } 130 loadedPlugins.Clear(); // remove all plugins once unloaded 131 132 foreach (var desc in PluginDescriptionIterator.IterateDependenciesBottomUp(plugins.Where(x => x.PluginState != PluginState.Disabled))) { 133 desc.Unload(); 134 OnPluginUnloaded(new PluginInfrastructureEventArgs(desc)); 135 } 136 plugins.Clear(); // remove all plugin descriptions once unloaded 137 } 138 139 /// <summary> 113 140 /// Runs the application declared in <paramref name="appInfo"/>. 114 141 /// This is a synchronous call. When the application is terminated all plugins are unloaded. … … 119 146 try { 120 147 runnablePlugin.Run(args); 121 } 122 finally { 123 // unload plugins in reverse order 124 foreach (var plugin in loadedPlugins.Reverse<IPlugin>()) { 125 plugin.OnUnload(); 126 } 127 foreach (var desc in PluginDescriptionIterator.IterateDependenciesBottomUp(plugins.Where(x => x.PluginState != PluginState.Disabled))) { 128 desc.Unload(); 129 OnPluginUnloaded(new PluginInfrastructureEventArgs(desc)); 130 } 148 } finally { 149 UnloadPlugins(); 131 150 } 132 151 }
Note: See TracChangeset
for help on using the changeset viewer.