public static void Main(string[] args)
    {
        var a = new ResourceConsumer("First");

        Run();
        GC.Collect();         //forcing garbage-collection
        a.Consume(101);

        AppDomain dom = AppDomain.CreateDomain("secondary");

        dom.DoCallBack(delegate()
        {
            var c = new ResourceConsumer("Third");
            c.Consume(103);
            var d = new ResourceConsumer("Fourth");
            d.Consume(104);
            d.Dispose();
        });
        AppDomain.Unload(dom);

        try
        {
            Run(args[0]);
        }
        catch {}

        Console.WriteLine("Press any key to exit...");
        Console.ReadKey();
    }
Example #2
0
 public void CheckType(ResourceConsumer toCheck)
 {
     if (toCheck.type == type)
     {
         if (toCheck.Consume(this))
         {
             Destroy(gameObject);
         }
     }
 }
 private static void Run(string arg)
 {
     /*
      * var e = new ResourceConsumer("Fifth");
      * try
      * {
      *      e.Consume(int.Parse(arg));
      * }
      * finally
      * {
      *      e.Dispose();
      * }
      */
     using (var e = new ResourceConsumer("Fifth"))
     {
         e.Consume(int.Parse(arg));
     }
 }
    private static void Run()
    {
        var b = new ResourceConsumer("Second");

        b.Consume(102);
    }