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

  • SEARCH
  • Home
  • 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 6873989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:08:19+00:00 2026-05-27T04:08:19+00:00

I got following code System.Diagnostics.Process capp = new System.Diagnostics.Process(); capp.StartInfo.UseShellExecute = false; capp.StartInfo.RedirectStandardOutput =

  • 0

I got following code

    System.Diagnostics.Process capp = new System.Diagnostics.Process();
    capp.StartInfo.UseShellExecute = false;
    capp.StartInfo.RedirectStandardOutput = true; 
    capp.StartInfo.RedirectStandardError = true;
    capp.EnableRaisingEvents = false;
    capp.StartInfo.FileName = "app.exe";
    capp.StartInfo.Arguments = "-i -v -mj";
    capp.Start();

    consoleOutput = capp.StandardOutput.ReadToEnd() + capp.StandardError.ReadToEnd();
    if (!capp.WaitForExit(10000)) capp.Kill(); 

and problem, if outside application works correctly it takes less than 10 seconds for it to complete its tasks. If it stop/hung for some reason despite of using

    if (!capp.WaitForExit(10000)) capp.Kill(); 

as suggested in some other topic, it keeps working. Above line seem not to work at all in my case, i guess it has to do with fact i read StandardOutput and StandardError. How to fix my code to make reading output and WaitForExit() to work aside?

  • 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. Editorial Team
    Editorial Team
    2026-05-27T04:08:20+00:00Added an answer on May 27, 2026 at 4:08 am

    If you don’t always read from both StandardOutput and StandardError the buffers can fill causing the process to block.

    You first try to read StandardOutput to the end. The process you run might be writing a lot of data to StandardError until it blocks and can’t write more. Then this results in your application blocking as it doesn’t even start reading from StandardError until the process closes its StandardOutput. This creates a deadlock and neither process will continue.

    I suggest you use the solution I’ve posted here. It uses asynchronous reads to read from both StandardOutput and StandardError, avoiding deadlocks.

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

Sidebar

Related Questions

I have following code: private void fileSystemWatcher_Changed(object sender, System.IO.FileSystemEventArgs e) { System.Diagnostics.Process execute =
I've got the following code to end a process, but I still receive an
I've got the following code: public void StartDataRequest() { WebRequest.RegisterPrefix(https://, System.Net.Browser.WebRequestCreator.ClientHttp); WebClient myService =
I got the following code: int nnames; String names[]; System.out.print(How many names are you
I got the following code: int nnames; String names[]; System.out.print(How many names are you
I have the following code: if (System.IO.File.Exists(htmlLocation)) { vEarthBrowser.ObjectForScripting = this; vEarthBrowser.Url = new
I got the following code to create a DLL : using System; using System.Collections.Generic;
I've got the following c# code: using System; using System.Collections.Generic; using System.Linq; using System.Text;
I got following code in an XHTML-document and every browser saysit is malformed :(
Ive got the following code which I hacked together from website examples. It works

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.