private void DeInitialize() { if (mnuMain.InvokeRequired) { mnuMain.Invoke(clearMenuItemsHandler); } else { mnuServiceOptions.DropDownItems.Clear(); } /*if (extStateService != null) * { * extStateService.ClearState(); * extStateService = null; * } * * if (emService != null) * { * emService.Stop(); * emService.Dispose(); * emService = null; * }*/ if (pluginManager != null) { // Unload our plugins foreach (CallButler.Service.Plugin.CallButlerServicePlugin plugin in pluginManager.Plugins) { plugin.Unload(); } pluginManager.UnloadPlugins(); pluginManager = null; } if (scriptService != null) { scriptService.Shutdown(); scriptService = null; } if (vmMailerService != null) { vmMailerService = null; } if (vmService != null) { vmService = null; } dataProvider = null; if (CallButlerService.DialPlanManager != null) { CallButlerService.DialPlanManager = null; } if (pbxRegistrar != null) { pbxRegistrar.Shutdown(); pbxRegistrar = null; } if (telecomProvider != null) { telecomProvider.Shutdown(); telecomProvider = null; } if (tcpManagementDataServer != null) { tcpManagementDataServer.StopServer(); } GC.Collect(); }