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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:30:13+00:00 2026-05-22T18:30:13+00:00

I am running a process on button click of my WPF application as shown

  • 0

I am running a process on button click of my WPF application as shown below:

private void btnGetValues_Click(object sender, RoutedEventArgs e)
{
    string arg1 = "1";
    Process p1 = new Process();
    p1.StartInfo.CreateNoWindow = true;
    p1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
    p1.StartInfo.FileName = "myexe.exe";
    p1.StartInfo.Arguments = arg1;
    p1.StartInfo.UseShellExecute = false;
    p1.StartInfo.RedirectStandardOutput = true;
    p1.StartInfo.RedirectStandardInput = true;
    p1.StartInfo.RedirectStandardError = true;
    p1.Start();

    //while (!p1.HasExited)
    //{

    //}

    MessageBox.Show(p1.StandardOutput.ReadToEnd());
}

The problem is that even after the process executes, the button continues to remain in clicked state. What could be the problem?

  • 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-22T18:30:13+00:00Added an answer on May 22, 2026 at 6:30 pm

    Why do you need the last message box? get read of it and it should work. If you are still experiencing problems then you can run it in a separate thread. That is a way of executing multiple things at the same time. here is an example.

    Edit

    sorry I understood the wrong thing. You can set the focus to something else if you wish the button to lose that appearance.

    private void button1_Click(object sender, EventArgs e)
            {
                string arg1 = "1";
                Process p1 = new Process();
                p1.StartInfo.CreateNoWindow = true;
                p1.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                p1.StartInfo.FileName = @"yourExecutable";
                p1.StartInfo.Arguments = arg1;
                p1.StartInfo.UseShellExecute = false;
                p1.StartInfo.RedirectStandardOutput = true;
                p1.StartInfo.RedirectStandardInput = true;
                p1.StartInfo.RedirectStandardError = true;
                p1.Start();
                //while (!p1.HasExited)
                //{
    
                // }
    
                MessageBox.Show(p1.StandardOutput.ReadToEnd());
    
                button2.Focus();  // set button 2 to have a height of 0 so it is not visible
                // or place it somewhere where it cannot be seen
    
    
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long running process in VB6 that I want to finish before
Suppose a long-running process writes to a log file. Suppose that log file is
I need to find the PID of the current running process on a Linux
Should I use Named Pipes, or .NET Remoting to communicate with a running process
I need a Java way to find a running Win process from which I
I'm running a long process stored procedure. I'm wondering if in case of a
I can get a list of running threads from Process.GetCurrentProcess().Threads, but I need to
I have an importer process which is running as a windows service (debug mode
I'm running some JMeter tests against a Java process to determine how responsive a
The 'attach to process' dialogue box on VC6 running on win 2003 (I believe

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.