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 7565649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:12:31+00:00 2026-05-30T14:12:31+00:00

I have an executable, which runs fine when i run it manually, and it

  • 0

I have an executable, which runs fine when i run it manually, and it exists as it should with the expected output. But when i run it with the method bellow, the Process.Exited event is never fired. Notice that i have remembered the Process.EnableRaisingEvents

protected override Result Execute(RunExecutable task)
{
    var process = new Process();
    process.StartInfo.Arguments = task.Arguments;
    process.StartInfo.FileName = task.ExecutablePath;
    process.StartInfo.CreateNoWindow = true;
    process.StartInfo.UseShellExecute = false;
    process.StartInfo.RedirectStandardOutput = true;
    process.EnableRaisingEvents = true;

    process.Exited += (sender, args) =>
    {
        processSync.OnNext(new Result
        {
            Success = process.ExitCode == 0,
            Message = process.StandardOutput.ReadToEnd()
        });
        processSync.OnCompleted();
    };
    process.Start();

    return processSync.First();;
}

The problem is the same, if i use Process.WaitForExit() instead of reactive extensions, to wait for the exit event.

Also, if i run the process with another argument, which produces another output, it exists fine.

It seems to have something to do with the process.StartInfo.RedirectStandardOutput = true; since when i disable this, it works. But that could just be a symptom of another problem.

Any help is appreciated 🙂

  • 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-30T14:12:33+00:00Added an answer on May 30, 2026 at 2:12 pm

    There’s a deadlock in your code. ‘Standard output’ is just a kind of named pipe, which has a small buffer to transfer data from one process to the other. If the buffer is full, the writing process has to wait for the reading process to retrieve some data from the buffer.

    So the process you have started might wait for you to read from the standard output, but you are waiting for the process to finish before you start reading -> deadlock.

    The solution is to read continuously while the process is running – just call StandardOutput.ReadToEnd() before you call WaitForExit().
    If you want to read without blocking the current thread, you can use BeginOutputReadLine() and the OutputDataReceived events.

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

Sidebar

Related Questions

I have a application executable, which runs with different parameters to produce different outputs.
I have an executable which is part of a batch process. This one executable
Assume I have an executable called 'exe' which spawns a child process. This child
I have an osx executable that runs succesfully. When I run nm mono |
I have an application that runs fine on .Net 2.0 SP2, but fails to
I have written a small program in WindowsXP-python-pygame. It runs fine when I run
I have a ATL COM service exe (MyService.exe), which compiles and runs fine. If
I have one program, which writes its output to stderr and it also runs
I have the following call which runs a method within a cacheListener object asynchronously:
I have a Windows executable (whoami) which is crashing every so often. It's called

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.