Started process hangs when redirected output is relatively big

nikolas.40

New Member
I ran into this problem today and it took me quite a while to figure it out. I was starting a process from within IIS, redirecting it's standard output and error output so when the process exited I'd be able to generate a log with it. Everything was running fine on my machine, but not so well after I published it.The process was supposed to work for just a while and then exit, however it just wouldn't. It'd simply stop responding, holding resources like sockets. After quite a while, I was able to identify the cause of the problem: the log generated was too big. After commenting \[code\]Console.WriteLine\[/code\] from the running process, everything worked just fine.Just for clarifying how I started the process:\[code\]Process process = new Process();process.StartInfo.FileName = path;process.StartInfo.Arguments = arguments;process.StartInfo.UseShellExecute = false;process.StartInfo.RedirectStandardOutput = true;process.StartInfo.RedirectStandardError = true;process.EnableRaisingEvents = true;process.Exited += Process_Exited;process.Start();\[/code\]And how I handled it's exit:\[code\]private static void Process_Exited(object sender, EventArgs e){ Process process = (Process)sender; File.WriteAllText(path, process.StandardOutput.ReadToEnd() + "\r\nEXCEPTIONS\r\n" + process.StandardError.ReadToEnd());}\[/code\]Even though I already know how to fix it, I'd still like to know what really happened and why, since there must be a way for me to create a log as big as I'd like.
 
Back
Top