void doShowPreferences() { if (preferencesWindow == null) { preferencesWindow = new formPreferences(); preferencesWindow.FormClosed += delegate(object sender, FormClosedEventArgs e) { preferencesWindow = null; }; } preferencesWindow.Show(); }