protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         configurationForm?.Dispose();
         configurationForm = null;
     }
 }
        public void ShowConfigurationForm()
        {
            if (configurationForm != null)
            {
                configurationForm.Activate();
                return;
            }

            appState.UpdateConfiguration();

            configurationForm = new ConfigureForm(appState.Configuration, machineLocator.ListMachines());

            if (configurationForm.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    configurationWriter.WriteConfiguration(configurationForm.UpdatedConfiguration);
                }
                catch (Exception e) when(e is InvalidOperationException || e is DirectoryNotFoundException)
                {
                    logger.LogError(e, $"Failed to write configuration {new { Error = e.Message }}");

                    MessageBox.Show(
                        $"Failed to write configuration, {e.Message}.",
                                    Properties.Resources.TrayTitle,
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Error
                                    );
                }

                appState.UpdateConfiguration();
            }

            configurationForm.Dispose();
            configurationForm = null;
        }