I have a method which starts a process. The process is a ruby script which queries an external source and returns something which is printed to a text file 'output.txt' and placed in the directory.
During execution, I run that method which looks like this:
p.StartInfo.FileName = @"blah directory";
p.StartInfo.WindowStyle = ProcessWindowStyle.Normal;
p.Start();
p.WaitForExit();
Then in my other method I say:
processmethod();
StreamReader sr = new StreamReader ("output.txt");
For some reason the ruby script is not finishing, because it isnt creating the output.txt file. I know it isnt a problem with the ruby script because if I execute it manually it works fine.
I'm guessing its some sort of timing issue. The weird thing is, this was working fine until yesterday with no alterations to that area of the code. I saw somewhere that 'waitforexit' locks the thread too so I'm not sure how this is getting to the streamreader at all without he process actually finishing first.
It also appears that the process simply terminates when the code moves on to the streamreader line, because the window closes and I still dont have an output file