public async Task Unload(WeakReference testAlcWeakRef, CheckModuleLoadContext alc) { alc.Unload(); alc = null; await Task.Run(() => { for (int i = 0; testAlcWeakRef.IsAlive && (i < 15); i++) { GC.Collect(); GC.WaitForPendingFinalizers(); } }); }
public async Task <bool> ReloadActions() { if (Actions.Count != 0) { Actions.Clear(); await _manager.Unload(_weakReference, _loadContext); } var result = await ModuleGovernor.BuildModule(GetComponentName()); ModuleGovernor.AllowBuild(); if (result) { _loadContext = new CheckModuleLoadContext(); FillActions(); } return(result); }
public Assembly Execute(out WeakReference testAlcWeakRef, out CheckModuleLoadContext alc, string pathToAssembly) { alc = new CheckModuleLoadContext(); testAlcWeakRef = new WeakReference(alc); return(alc.LoadFromAssemblyPath(pathToAssembly));; }