Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 117711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:22:46+00:00 2026-05-11T03:22:46+00:00

I wrote a quick and dirty wrapper around svn.exe to retrieve some content and

  • 0

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 finish. For example, one call is to svn list:

svn list 'http://myserver:84/svn/Documents/Instruments/' --xml  --no-auth-cache --username myuser --password mypassword 

This command line runs fine when I just do it from a command shell, but it hangs in my app. My c# code to run this is:

string cmd = 'svn.exe'; string arguments = 'list \'http://myserver:84/svn/Documents/Instruments/\' --xml  --no-auth-cache --username myuser --password mypassword'; int ms = 5000; ProcessStartInfo psi = new ProcessStartInfo(cmd); psi.Arguments = arguments; psi.RedirectStandardOutput = true; psi.WindowStyle = ProcessWindowStyle.Normal; psi.UseShellExecute = false; Process proc = Process.Start(psi); StreamReader output = new StreamReader(proc.StandardOutput.BaseStream, Encoding.UTF8);  proc.WaitForExit(ms); if (proc.HasExited) {     return output.ReadToEnd(); } 

This takes the full 5000 ms and never finishes. Extending the time doesn’t help. In a separate command prompt, it runs instantly, so I’m pretty sure it’s unrelated to an insufficient waiting time. For other inputs, however, this seems to work fine.

I also tried running a separate cmd.exe here (where exe is svn.exe and args is the original arg string), but the hang still occurred:

string cmd = 'cmd'; string arguments = '/S /C \'' + exe + ' ' + args + '\''; 

What could I be screwing up here, and how can I debug this external process stuff?

EDIT:

I’m just now getting around to addressing this. Mucho thanks to Jon Skeet for his suggestion, which indeed works great. I have another question about my method of handling this, though, since I’m a multi-threaded novice. I’d like suggestions on improving any glaring deficiencies or anything otherwise dumb. I ended up creating a small class that contains the stdout stream, a StringBuilder to hold the output, and a flag to tell when it’s finished. Then I used ThreadPool.QueueUserWorkItem and passed in an instance of my class:

ProcessBufferHandler bufferHandler = new ProcessBufferHandler(proc.StandardOutput.BaseStream,                                                                           Encoding.UTF8); ThreadPool.QueueUserWorkItem(ProcessStream, bufferHandler);  proc.WaitForExit(ms); if (proc.HasExited) {     bufferHandler.Stop();     return bufferHandler.ReadToEnd(); } 

… and …

private class ProcessBufferHandler {     public Stream stream;     public StringBuilder sb;     public Encoding encoding;     public State state;      public enum State     {         Running,         Stopped     }      public ProcessBufferHandler(Stream stream, Encoding encoding)     {         this.stream = stream;         this.sb = new StringBuilder();         this.encoding = encoding;         state = State.Running;     }     public void ProcessBuffer()     {         sb.Append(new StreamReader(stream, encoding).ReadToEnd());     }      public string ReadToEnd()     {         return sb.ToString();     }      public void Stop()     {         state = State.Stopped;     } } 

This seems to work, but I’m doubtful that this is the best way. Is this reasonable? And what can I do to improve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:22:47+00:00Added an answer on May 11, 2026 at 3:22 am

    One standard issue: the process could be waiting for you to read its output. Create a separate thread to read from its standard output while you’re waiting for it to exit. It’s a bit of a pain, but that may well be the problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a quick program in python to add a gtk GUI to a
Hey guys i wrote a quick test. I want delete to call deleteMe which
Wrote the following in PowersHell as a quick iTunes demonstration: $iTunes = New-Object -ComObject
I wrote a windows service using VB that read some legacy data from Visual
I'm trying to write a quick little java application to read the contents of
In my classes I often write a quick operator!= by returning !(*this == rhs)
I wrote a simple batch file as a PowerShell script, and I am getting
I wrote myself a little downloading application so that I could easily grab a
I wrote a component that displays a filename, a thumbnail and has a button

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.