From b7be2c76dc5b67c66e0a7854904054bb745f60a3 Mon Sep 17 00:00:00 2001 From: Erik van den Brink Date: Thu, 31 Oct 2019 05:18:20 +0100 Subject: [PATCH] Add shutdown event for plugins (#1195) * add shutdown event for plugins * use IDisposable * dispose plugins first * Removing brackets --- neo/NeoSystem.cs | 2 ++ neo/Plugins/Plugin.cs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/neo/NeoSystem.cs b/neo/NeoSystem.cs index 867d4e4201..9265f47645 100644 --- a/neo/NeoSystem.cs +++ b/neo/NeoSystem.cs @@ -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() diff --git a/neo/Plugins/Plugin.cs b/neo/Plugins/Plugin.cs index aa04b0778d..14345d9de1 100644 --- a/neo/Plugins/Plugin.cs +++ b/neo/Plugins/Plugin.cs @@ -8,7 +8,7 @@ namespace Neo.Plugins { - public abstract class Plugin + public abstract class Plugin : IDisposable { public static readonly List Plugins = new List(); private static readonly List Loggers = new List(); @@ -169,5 +169,9 @@ private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEven return null; } } + + public virtual void Dispose() + { + } } }