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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:39:06+00:00 2026-06-13T06:39:06+00:00

I need to execute my console app for many files in a loop and

  • 0

I need to execute my console app for many files in a loop and update my GUI. When I execute my app for the first time everything is ok, GUI updates are done in realtime. But with every iteration, reading of console output get longer delay. After 3-4 files I get only few updates or no updates at all. Its not a problem with updating GUI, my dataraceivedevent doesn’t fire up.

I can’t understand why, because after every iteration I close and dispose my process.

This is the method that I execute in the for-loop.

public void execute(string arguments, string path)
    {
        Process myProcess = new Process();
        myProcess.StartInfo.CreateNoWindow = true;
        myProcess.StartInfo.FileName = path;
        myProcess.StartInfo.UseShellExecute = false;
        myProcess.StartInfo.RedirectStandardOutput = true;
        myProcess.StartInfo.Arguments = arguments;
        myProcess.Start();
        myProcess.BeginOutputReadLine();
        myProcess.OutputDataReceived += new DataReceivedEventHandler(this.updateProgress);
        myProcess.WaitForExit();
        myProcess.CancelOutputRead();
        myProcess.OutputDataReceived -= updateProgress;
        myProcess.Close();
        myProcess.Dispose();

        if (progressBar1.InvokeRequired)
        {
            progressBar1.BeginInvoke(new Action(() =>
            {
                progressBar1.PerformStep();
            }));
        }
        else
        {
            progressBar1.PerformStep();
        }

        if (progressBar2.InvokeRequired)
        {
            progressBar2.BeginInvoke(new Action(() =>
            {
                progressBar2.Value = 100;
                progressBar2.Refresh();
            }));
        }
        else
        {
            progressBar2.Value = 100;
            progressBar2.Refresh();
        }

        if (this.InvokeRequired)
        {
            this.BeginInvoke(new Action(() =>
            {
                this.Text = " ";
            }));
        }
        else
        {
            this.Text = " ";
        }
        Thread.Sleep(500);

    }
  • 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-13T06:39:08+00:00Added an answer on June 13, 2026 at 6:39 am

    I had the same problem after executing 100K times, for the last time the myProcess.WaitForExit(); took so much time. Instead, you can use the other overload which takes an integer indicating how many milliseconds the process has time to exit.
    myProcess.WaitForExit(1000);

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

Sidebar

Related Questions

I have a .exe program (console app) written in .net. I need to execute
I need execute some code before Windows shutdown process each time. So, I want
I am trying to execute a console app with arguments inside asp.net (C#) on
i have done coding in C# but not much inside the Console App (teacher
I need NAnt to kick off a long running console app on the local
I need to execute the less command, with paging, from my Java console application.
I have a C# console application (A). I want to execute other console app
I need to execute and send command to external app from python: .\Ext\PrintfPC /p
I need to execute some periodic console applications that give me some results (on
In a metro app, I need to execute a number of WCF calls. There

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.