title: The advantages of using AppDomain in C# with Proxy Pattern?
body: <p>I have code to implement <a href="http://www.dofactory.com/Patterns/Patterns.aspx" rel="nofollow noreferrer">GoF's proxy pattern in C#</a>. The code has MathProxy for calculating arithmetic functions. </p>
  
  <p>The left side example is one implementation, and the right side is the better one for C# (.NET) with  AppDomain. </p>
  
  <p>What benefits can I expect using AppDomain especially with Proxy Pattern?</p>
  
  <pre><code>public MathProxy()
  {
      // Create Math instance in a different AppDomain
      var ad =  AppDomain.CreateDomain("MathDomain", null, null);
  
      var o = ad.CreateInstance(
          "DoFactory.GangOfFour.Proxy.NETOptimized",
          "DoFactory.GangOfFour.Proxy.NETOptimized.Math");
      _math = (Math)o.Unwrap();
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/81X5W.png" alt="enter image description here"></p>