public static AppDomainAdapter Use(string name) { AppDomainAdapter ad = null; if (!cache.ContainsKey(name)) { var dm = AppDomain.CreateDomain(name, AppDomain.CurrentDomain.Evidence); ad = new AppDomainAdapter(dm); cache[name] = ad; } ad = cache[name]; return(ad); }
public static void Unload(string name) { if (cache.ContainsKey(name)) { AppDomainAdapter o = null; while (!cache.TryRemove(name, out o)) { Thread.Sleep(100); } if (o != null) { o.Unload(); } } }