1. I did try without trying to read output or trying to read only first line of the output - both of these were successful.
2. However when I try to display full output, it just gets stuck and does nothing.
3. Even more crazy stuff - when I close the application, I am able to see some output for a split second.
4. I tried printing line by line and it gets stuck on the last line, however no bug or error is generated. It is just sitting there and that's it.
What is going on? :( It was quite difficult for me to find out how to interact with the program and now that I am successful (because everything is working), it just won't work for some reason.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Threading;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
ProcessStartInfo processStartInfo = new ProcessStartInfo("Rybka32.exe", "");
processStartInfo.UseShellExecute = false;
processStartInfo.ErrorDialog = false;
processStartInfo.RedirectStandardError = true;
processStartInfo.RedirectStandardInput = true;
processStartInfo.RedirectStandardOutput = true;
Process process = new Process();
process.StartInfo = processStartInfo;
bool processStarted = process.Start();
StreamWriter inputWriter = process.StandardInput;
StreamReader outputReader = process.StandardOutput;
StreamReader errorReader = process.StandardError;
List<String> commands = new List<String>();
commands.Add("uci");
commands.Add("setoption name Hash value 32");
commands.Add("setoption name NalimovCache value 1");
commands.Add("setoption name NalimovPath value d:\tb;c\tb");
commands.Add("isready");
commands.Add("ucinewgame");
commands.Add("setoption name UCI_AnalyseMode value true");
commands.Add("position startpos moves e2e4 g7g5 d2d4 f7f6");
foreach (String command in commands)
{
System.Console.WriteLine("==>:" + command);
inputWriter.WriteLine(command);
string result = outputReader.ReadToEnd();
System.Console.WriteLine(result);
System.Console.WriteLine("This message is not written for some reason and the program seems to be stuck. *cries*");
}
System.Console.ReadKey();
}
}
}