/// <summary> /// Run the specified plugin on the current thread, or on the /// synchronized context if it was specified. /// </summary> /// <param name="plugin">The plugin to reload.</param> /// <param name="reload">Optionally reload the plugin before running.</param> private void RunPlugin(IIronPlugin plugin, bool reload) { try { if (_reloadContext == null) { Reload(new object[] { plugin, reload, false }); } else { _reloadContext.Send( new System.Threading.SendOrPostCallback(Reload), new object[] { plugin, reload, true }); } } catch (Exception e) { if (PluginReloadedError != null) { PluginReloadErrorEventArgs args = new PluginReloadErrorEventArgs(plugin, e); if (_reloadContext == null) OnPluginReloadError(args); else _reloadContext.Send( new System.Threading.SendOrPostCallback(delegate(object data) { OnPluginReloadError(args); }), null); } else throw e; } }
/// <summary> /// A plugin was changed and while trying to reload it, the manager encountered an error. /// </summary> /// <param name="sender"></param> /// <param name="args"></param> void _pluginManager_PluginReloadedError(object sender, PluginReloadErrorEventArgs args) { string message = string.Format("Error while reloading {0}:\r\n{1}", args.Plugin.ToString(), args.Error.Message); MessageBox.Show(message); }
/// <summary> /// Raise the PluginReloadedError event. /// </summary> /// <param name="args"></param> protected virtual void OnPluginReloadError(PluginReloadErrorEventArgs args) { if (PluginReloadedError != null) PluginReloadedError(this, args); }