public void Dispose() { if (wpf != null) { wpf.Closed -= wpfClosed; wpf = null; } else if (winform != null) { winform.FormClosed -= winformClosed; winform = null; } Disposing?.Invoke(this, EventArgs.Empty); }