private void Close() { if (startServiceMenuItem != null) { startServiceMenuItem.Dispose(); startServiceMenuItem = null; } if (stopServiceMenuItem != null) { stopServiceMenuItem.Dispose(); stopServiceMenuItem = null; } if (exitMenuItem != null) { exitMenuItem.Dispose(); exitMenuItem = null; } if (notifyIcon != null) { notifyIcon.ContextMenuStrip.Opening -= ContextMenuStrip_Opening; notifyIcon.DoubleClick -= NotifyIcon_DoubleClick; notifyIcon.MouseUp -= NotifyIcon_MouseUp; notifyIcon.Dispose(); notifyIcon = null; } if (aboutViewModel != null) { aboutViewModel.Dispose(); aboutViewModel = null; } if (statusViewModel != null) { statusViewModel.Dispose(); statusViewModel = null; } if (hiddenWindow != null) { hiddenWindow.Close(); hiddenWindow = null; } if (components != null) { components.Dispose(); components = null; } }