private void btnQuit_Click(System.Object sender, System.EventArgs e) { taskbarIcon.Dispose(); if ((hostIDBrowserService != null)) { if (hostIDBrowserService.State == System.ServiceModel.CommunicationState.Opened) { hostIDBrowserService.Close(); } } Application.Current.Shutdown(); }
protected override void OnExit(ExitEventArgs e) { notifyIcon.Dispose(); //the icon would clean up automatically, but this is cleaner base.OnExit(e); }