public void InvokeEx(MgaProject project, MgaFCO currentobj, MgaFCOs selectedobjs, int param) { if (!enabled) { return; } if (currentobj == null) { MessageBox.Show("Please select the subtree to be replaced (via merge) so that it is displayed in the main window."); return; } currentMgaProject = project; try { gmeConsole = new FlexConsole(FlexConsole.ConsoleType.GMECONSOLE, project); MgaGateway = new MgaGateway(project); Main(project, currentobj, selectedobjs, Convert(param)); } finally { MgaGateway = null; project = null; currentobj = null; selectedobjs = null; gmeConsole = null; GC.Collect(); GC.WaitForPendingFinalizers(); } }