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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:16:15+00:00 2026-06-09T23:16:15+00:00

Since StandardOutput isn’t reactive I need a way to observe it. I know Process

  • 0

Since StandardOutput isn’t reactive I need a way to observe it.
I know Process class exposes an event for receiving notifications when output has been written
so I used this extension method to get an IObservable for the standard output

public static class ProcessExtensions
{
    public static IObservable<string> StandardOutputObservable(this Process process)
    {
        process.EnableRaisingEvents = true;
        process.StartInfo.RedirectStandardOutput = true;

        var received = Observable.FromEventPattern<DataReceivedEventHandler,DataReceivedEventArgs>(
            handler => handler.Invoke,
            h => process.OutputDataReceived += h,
            h => process.OutputDataReceived -= h)
            .TakeUntil(Observable.FromEventPattern(
                h => process.Exited += h,
                h => process.Exited -= h))
            .Select(e => e.EventArgs.Data);

        process.BeginOutputReadLine();

        return received;

        /* Or if cancellation is important to you...
        return Observable.Create<string>(observer =>
            {
                var cancel = Disposable.Create(process.CancelOutputRead);

                return new CompositeDisposable(
                    cancel, 
                    received.Subscribe(observer));
            });
         */
    }
}

as found here.
But when I start the process

public sealed class ProgramHelper
{
    private readonly Process _program = new Process();
    public IObservable<string> ObservableOutput { get; private set; }

    public ProgramHelper(string programPath, string programArgs)
    {
        _program.StartInfo.FileName = programPath;
        _program.StartInfo.Arguments = programArgs;
    }

    public void StartProgram()
    {
        ConfigService.SaveConfig(
            new Config(
                new Uri(@"http://some.url.com")));

        _program.Start();

        ObservableOutput = _program.StandardOutputObservable();

    }
}

...

[TestFixture]
public class When_program_starts
{
    private ProgramHelper _program;

    [Test]
    public void It_should_not_complain()
    {
       //W
       Action act = () => _program.StartProgram();
       //T
       act.ShouldNotThrow<Exception>();
    }
}

I get this error:

“StandardOut has not been redirected or the process hasn’t started yet.”

Thank you for your time.

EDIT:
edited the ProgramHelper to

    public ProgramHelper(string programPath, string programArgs)
    {
        _program.StartInfo.FileName = programPath;
        _program.StartInfo.Arguments = programArgs;
        _program.EnableRaisingEvents = true;
        _program.StartInfo.UseShellExecute = false;
        _program.StartInfo.RedirectStandardOutput = true;
    }

but now it throws “Access is denied exception”.

It seems I don’t have permission to start the process programmatically; if I start the exe from console it works just fine.

  • 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-06-09T23:16:16+00:00Added an answer on June 9, 2026 at 11:16 pm

    You are mutating the Process.StartInfo property after the process has been started.

    From the Process.StartInfo MSDN documentation:

    You can change the parameters specified in the StartInfo property up to the time that you call the Start method on the process. After you start the process, changing the StartInfo values does not affect or restart the associated process.

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

Sidebar

Related Questions

Since TabActivity is deprecated I need to find a way to do it with
Since now I have only used plugin for editing and the way I use
Since I have no errors I don't know if this is the right place
Since I embeded fetch request in my model.xcdatamodeld, I need an instance of NSManagedObjectModel
Since yesterday I am looking for a way to save (mysql + php) dragged
Since I am a newbie in iPhone development, I need some advice on how
Since the WMI class Win32_OperatingSystem only includes OSArchitecture in Windows Vista, I quickly wrote
Since typedef is a storage class in C, it cannot be used with static
Since EF doesn't support unique key contraints, it seems that we need to catch
Since i'm writing a game in RoR, i need to have a game loop

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.