void ServerProcessOutputRecieved(object sender, DataReceivedEventArgs args) { if (args.Data != null && interfaceForm != null) { try { //run code on ui thread interfaceForm.Invoke((MethodInvoker) delegate { interfaceForm.ConsoleOutputTextBox.AppendText(args.Data); }); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } } }