请问winform怎么注册进程结束事件

解决方案 »

  1.   

     
    Application.ApplicationExit += (Application_ApplicationExit);void Application_ApplicationExit(object sender, EventArgs e)
    {
                }
      

  2.   


    using System;
    using System.Threading;
    using System.Reflection;
    using System.Windows.Forms;
       public class HelloWorldForm : Form
    {
        public HelloWorldForm()
        {
            Text = "Hello, WindowsForms!";
        }
    }
       
    public class ApplicationEventHandlerClass
    {
        public void OnApplicationExit(object sender, EventArgs e)
        {
            try
            {
                Console.WriteLine("The application is shutting down.");
            }
            catch(NotSupportedException)
            {
            }
        }
    }
       
    public class MainClass
    {
        public static void Main()
        {
            HelloWorldForm FormObject = new HelloWorldForm();
            ApplicationEventHandlerClass AppEvents = new ApplicationEventHandlerClass();
       
            Application.ApplicationExit += new EventHandler(AppEvents.OnApplicationExit);
            Application.Run(FormObject);
        }
    }
      

  3.   


    进程是内核对象, 可以wait, 也可以从这个角度做
      

  4.   

    我的进程名字是 abc.exe请问   在abc.exe进程结束后 执行代码代码a=2,,,
      

  5.   

    public class HelloWorldForm : Form
    {
        public HelloWorldForm()
        {
            Text = "Hello, WindowsForms!";
        }
    }
       
    public class ApplicationEventHandlerClass
    {
        public void OnApplicationExit(object sender, EventArgs e)
        {
            try
            {
                Console.WriteLine("The application is shutting down.");
            }
            catch(NotSupportedException)
            {
            }
        }
    }
       
    public class MainClass
    {
        public static void Main()
        {
            HelloWorldForm FormObject = new HelloWorldForm();
            ApplicationEventHandlerClass AppEvents = new ApplicationEventHandlerClass();
       
            Application.ApplicationExit += new EventHandler(AppEvents.OnApplicationExit);
            Application.Run(FormObject);
        }
    }