Handle AppDomain Event : AppDomain : Assembly C# Examples


C# Examples » Assembly » AppDomain »

 

Handle AppDomain Event









    
using  System;
using  System.Reflection;
using  System.Windows.Forms;
    
public  class  MainClass
{
    public  static  void  defaultAD_DomainUnload(object  sender,  EventArgs  e)
    {
        Console.WriteLine("Unloaded  defaultAD!");
    }
    private  static  void  defaultAD_ProcessExit(object  sender,  EventArgs  e)
    {
        Console.WriteLine("Unloaded  defaultAD!");
    }

    public  static  int  Main(string[]  args)
    {
        AppDomain  defaultAD  =  AppDomain.CreateDomain("SecondAppDomain");

        defaultAD.DomainUnload  +=  new  EventHandler(defaultAD_DomainUnload);
        defaultAD.ProcessExit  +=new  EventHandler(defaultAD_ProcessExit);

        //  Now  unload  anotherAD.
        AppDomain.Unload(defaultAD);

        return  0;
    }
}
    
   
  
   



Output

Unloaded defaultAD!


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Assembly
» AppDomain