Controlling the Number of Processes Running.

Hi,

Ive created a small app which reads a list of excel documents from a database.  These excel sheets when opened run a macro which refresh other sheets, once that is done the sheet closes automatically.

What i want to do is limit the number of jobs that the app kicks off to around 2 but how can i tell when the Excel sheet ive opened is finished running its macro.  When i start the process can i check to see when it has closed

At the moment im using
[code]
System.Diagnostics.Process.Start("excel", _jobfilepath)
[/code]
to start the Excel process.  Can i tell when that Process stops or ends




Answer this question

Controlling the Number of Processes Running.

  • Tailwag

    Can you give me an example oh how i would do that.

    I have a class called Job which has a sub called Run, which obviously enough runs the job.  How can i get the job class to handle the Process.Exited event

  • Stephen Leach

    Try the following:


    ...

    public void Start()
    {
       Process process = Process.Start("excel", _jobfilepath);

       process.Exited += new EventHandler(OnProcessExited);
    }

    private void OnProcessExited(object sender, EventArgs e)
    {
       MessageBox.Show("The process exited.");
    }



     


  • CamCam

    Attach and handle the Process.Exited event.

  • Controlling the Number of Processes Running.