Hanging process when run with .NET Process.Start — what's wrong?

后端 未结 5 1015
粉色の甜心
粉色の甜心 2020-12-03 01:25

I wrote a quick and dirty wrapper around svn.exe to retrieve some content and do something with it, but for certain inputs it occasionally and reproducibly hangs and won\'t

5条回答
  •  有刺的猬
    2020-12-03 01:52

    Jon Skeet is right on the money!

    If you don't mind polling after you launch your svn command try this:

    Process command = new Process();
    command.EnableRaisingEvents = false;
    command.StartInfo.FileName = "svn.exe";
    command.StartInfo.Arguments = "your svn arguments here";
    command.StartInfo.UseShellExecute = false;
    command.StartInfo.RedirectStandardOutput = true;
    command.Start();
    
    while (!command.StandardOutput.EndOfStream)
    {
        Console.WriteLine(command.StandardOutput.ReadLine());
    }
    

提交回复
热议问题