1

I'm trying to get output from node server into a multiline textbox but every time I launch my application, the WinForms window do not open until I close the node process from task manager.

Here is the code:

private void Form1_Load(object sender, EventArgs e)
        {
            var processStartInfo = new ProcessStartInfo
            {
                FileName = "node",
                Arguments = "src",
                RedirectStandardOutput = true,
                UseShellExecute = false,
                CreateNoWindow = true
            };
            var process = Process.Start(processStartInfo);
            var output = process.StandardOutput.ReadToEnd();
            process.WaitForExit();
            materialMultiLineTextBox1.Text = output;
        }
marek9911
  • 11
  • 1
  • You're calling `WaitForExit` (or even, `ReadToEnd()` - it can only reasonably return when the stream ends) using the thread that is responsible for drawing the user interface. If you make that thread busy for a long time you'll notice the UI of the program jams (in this case before it's had a chance to even show the window, let alone draw in it).. And by all accounts `node` isn't actually exiting until you quit it so, some re-engineering of the thougt process is required here; you'll wait for a long time if you start waiting for a program to exit when it doesn't actually exit – Caius Jard Jan 20 '22 at 19:00
  • [How do I get output from a command to appear in a control on a Form in real-time?](https://stackoverflow.com/a/51682585/7444103) – Jimi Jan 20 '22 at 19:42

0 Answers0