3
Answers

console output froozing app

david seinfeild

david seinfeild

11y
1.2k
1
im trying to get the console output to a textbox

but whenever i start the process it freeze my app till i have to crash it

heres my code so far


     thingstohidewhenclosingsettings();
            thingstoshowfornotebook();

            Process myProcess2 = new Process();
            myProcess2.StartInfo.FileName = @"C:\Windows\System32\cmd.exe";          
            myProcess2.StartInfo.UseShellExecute = false;
            myProcess2.StartInfo.CreateNoWindow = true;
            myProcess2.StartInfo.RedirectStandardInput = true;
            myProcess2.StartInfo.RedirectStandardOutput = true;
          
            myProcess2.Start();

            
            StreamWriter myStreamWriter3 = myProcess2.StandardInput;
            myStreamWriter3.WriteLine("netstat -n");
            StreamReader myStreamWriter4 = myProcess2.StandardOutput;
            string outputx = myProcess2.StandardOutput.ReadToEnd();
            
             myProcess2.WaitForInputIdle();
             int exitCode = myProcess2.ExitCode;
             myProcess2.Close();
             notebookbox.Text = outputx;
             return;

Answers (3)