[Mono-list] System.Diagnostics.Process.Exited Event

Jose Luis Garcia jlgarcia@montytronic.com
Mon, 27 Oct 2003 12:12:58 +0100


hi again

Sorry for my stupid post, I have read only the first part of the original
message.

Here is a sample code that works on MS platform... I can't test now on Linux

Josus.

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Diagnostics;

namespace processTest
{
 /// <summary>
 /// Descripción breve de Form1.
 /// </summary>
 public class Form1 : System.Windows.Forms.Form
 {
  /// <summary>
  /// Variable del diseñador requerida.
  /// </summary>
  private System.ComponentModel.Container components = null;
  private Process process;

  public Form1()
  {
   //
   // Necesario para admitir el Diseñador de Windows Forms
   //
   InitializeComponent();

   //
   // TODO: agregar código de constructor después de llamar a
InitializeComponent
   //
  }

  /// <summary>
  /// Limpiar los recursos que se estén utilizando.
  /// </summary>
  protected override void Dispose( bool disposing )
  {
   if( disposing )
   {
    if (components != null)
    {
     components.Dispose();
    }
   }
   base.Dispose( disposing );
  }

  #region Código generado por el Diseñador de Windows Forms
  /// <summary>
  /// Método necesario para admitir el Diseñador. No se puede modificar
  /// el contenido del método con el editor de código.
  /// </summary>
  private void InitializeComponent()
  {
   //
   // Form1
   //
   this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
   this.ClientSize = new System.Drawing.Size(292, 266);
   this.Name = "Form1";
   this.Text = "Form1";
   this.Load += new System.EventHandler(this.Form1_Load);

  }
  #endregion

  /// <summary>
  /// Punto de entrada principal de la aplicación.
  /// </summary>
  [STAThread]
  static void Main()
  {
   Application.Run(new Form1());
  }

  private void Form1_Load(object sender, System.EventArgs e)
  {
   this.process = new System.Diagnostics.Process();
   this.process.EnableRaisingEvents = true;
   this.process.StartInfo.FileName = "notepad.exe";
   this.process.Start();
   this.process.Exited += new EventHandler(this.process_Exited);
  }

  private void process_Exited(object sender, EventArgs e)
  {
   MessageBox.Show("IExplorer.exe finalizó su ejecución");
   this.process.Dispose();
   this.process = null;
  }
 }
}


----- Original Message ----- 
From: "Jose Luis Garcia" <jlgarcia@montytronic.com>
To: "Ecmel Ercan" <ecmel@ercansoy.com>; <mono-list@lists.ximian.com>
Sent: Monday, October 27, 2003 11:02 AM
Subject: Re: [Mono-list] System.Diagnostics.Process.Exited Event


> hi,
>
>     Without your code i thing it's posible you're not enable the process
to
> raise events...
>
>    process.EnableRaisingEvents = true;
>
> Josus.
>
> ----- Original Message ----- 
> From: "Ecmel Ercan" <ecmel@ercansoy.com>
> To: <mono-list@lists.ximian.com>
> Sent: Saturday, October 25, 2003 8:13 PM
> Subject: [Mono-list] System.Diagnostics.Process.Exited Event
>
>
> > Hi,
> >
> > Hope I am posting to the correct list.
> >
> > I try to execute a process by using the System.Diagnostics.Process
class.
> >
> > Everything works fine but the System.Diagnostics.Process.Exited Event
does
> > not fire when the process finishes.
> >
> > I set System.Diagnostics.Process.EnableRaisingEvents to true.
> >
> > I am using mono 0.28
> >
> > Hope someone can help.
> >
> > Best Regards,
> > Ecmel Ercan
> >
> >
> > _______________________________________________
> > Mono-list maillist  -  Mono-list@lists.ximian.com
> > http://lists.ximian.com/mailman/listinfo/mono-list
> >
>
> _______________________________________________
> Mono-list maillist  -  Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>