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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:02:32+00:00 2026-05-26T02:02:32+00:00

In my current project I’m taking a command prompt and pretty much displaying it

  • 0

In my current project I’m taking a command prompt and pretty much displaying it on a richTextBox based on an input typed in a textBox and a button is pressed.

See Having trouble with Process class while redirecting command prompt output to winform

One small update I want to make (might not be a particularly small update code-wize) is to have the button in a “disabled” state while the command prompt is doing it’s execution. Since the project uses “Control.BeginInvoke” to update the text on the richTextBox, it does a “fire and forget.” This means there isn’t really a way I can re-enable a disabled button once all the “BeginInvokes” have been processed to the UI.

I guess the question is, is it possible to get a callback once all the “BeginInvokes” have been executed and say “Hey I’m done, here is your button back.” This will prevent a user from hitting the button sending duplicate processes.

Here is a snippet of the code I’m using:

public void GetConsoleOuput(string command = null)
{
    ProcessStartInfo startInfo = new ProcessStartInfo();
    startInfo.FileName = "cmd.exe";
    startInfo.RedirectStandardOutput = true;
    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
    startInfo.UseShellExecute = false;
    startInfo.CreateNoWindow = true;

    if (!string.IsNullOrEmpty(command))
    {
        startInfo.Arguments = command;
    }

    Process process = new Process();
    process.StartInfo = startInfo;
    process.OutputDataReceived += new DataReceivedEventHandler(AppendRichBoxText);

    process.Start();
    process.BeginOutputReadLine();
    process.Close();
}

public void AppendRichBoxText(object sendingProcess, DataReceivedEventArgs outLine)
{
    string outputString = args.Data;
    MethodInvoker append = () => richTextBox.AppendText(outputString);
    richTextBox.BeginInvoke(append);
}

// Would like EventHandler method to enable button once all "BeginInvokes" are
// done running asynchronously due to a callback.
public void EnableButton
{
    /// re-enable a disabled button
}
  • 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-26T02:02:32+00:00Added an answer on May 26, 2026 at 2:02 am

    Just call BeginInvoke again after all of your updates to call EnabledButton afterwards.

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

Sidebar

Related Questions

Current Project Setup I've been working on a web-based chat, similar to Facebook chat.
In my current project, I have a textbox where the user will enter some
my current project is based on Entity Framwork code-first. I have three types: Task,
My current project is a form that receives input from a user. After I
My current project has us using TreeSet and TreeMap in Java, with an input
My current project is in Rails. Coming from a Symfony (PHP) and Django (Python)
My current project uses NUnit for unit tests and to drive UATs written with
My current project involves deploying an upgraded .exe file that runs as a Windows
My current project involves writing Perl code inside a Solaris VMWare appliance (hosted on
My current project is broken down into 3 parts: Website, Desktop Client, and a

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.