Skip to content

Commit

Permalink
Add shutdown event for plugins (#1195)
Browse files Browse the repository at this point in the history
* add shutdown event for plugins

* use IDisposable

* dispose plugins first

* Removing brackets
  • Loading branch information
ixje authored and lock9 committed Oct 31, 2019
1 parent 1b7d1ec commit b7be2c7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions neo/NeoSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public NeoSystem(Store store)

public void Dispose()
{
foreach (var p in Plugin.Plugins)
p.Dispose();
RpcServer?.Dispose();
EnsureStoped(LocalNode);
// Dispose will call ActorSystem.Terminate()
Expand Down
6 changes: 5 additions & 1 deletion neo/Plugins/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Neo.Plugins
{
public abstract class Plugin
public abstract class Plugin : IDisposable
{
public static readonly List<Plugin> Plugins = new List<Plugin>();
private static readonly List<ILogPlugin> Loggers = new List<ILogPlugin>();
Expand Down Expand Up @@ -169,5 +169,9 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven
return null;
}
}

public virtual void Dispose()
{
}
}
}

0 comments on commit b7be2c7

Please sign in to comment.