void Context_ShowInterface(object sender, EventArgs e) { if (interfaceForm == null) { interfaceForm = new ServerInterfaceForm(this); interfaceForm.Closed += interfaceForm_Closed; interfaceForm.Show(); } else { interfaceForm.Activate(); } //run code on ui thread interfaceForm.Invoke((MethodInvoker) delegate { interfaceForm.ConsoleOutputTextBox.AppendText(serverProcessOutput); interfaceForm.StartServerButton.Enabled = !serverRunning; interfaceForm.StopServerButton.Enabled = serverRunning; }); }
void interfaceForm_Closed(object sender, EventArgs e) { interfaceForm = null; }