public object InvokeMemberInternal(XrayHandle self, string name, object[] args) { if (args is null) { throw new ArgumentNullException(nameof(args)); } if (!CefApi.CurrentlyOn(CefThreadId.Renderer)) { using (var callTask = new V8CallTask(() => InvokeMemberInternal(self, name, args))) { if (!CefApi.PostTask(CefThreadId.Renderer, callTask)) { throw new InvalidOperationException(); } return((bool)callTask.GetResult()); } } XrayObject target = self.GetTarget(this.Frame); if (target is null || !target.Context.Enter()) { throw new InvalidOperationException(); } object retval; try { CefV8Value thisArg = target.Value; CefV8Value func = thisArg.GetValueByKey(name); if (!func.IsFunction) { func.Dispose(); throw new MissingMethodException(string.Format("'{0} is not a function.'", name)); } CefV8Value value; var xraylist = new List <int>(args.Length); var fnArgs = new CefV8Value[args.Length]; try { for (int i = 0; i < fnArgs.Length; i++) { fnArgs[i] = CastDotnetTypeToCefV8Value(target.Context, args[i], out bool isNew); if (!isNew) { xraylist.Add(i); } } value = func.ExecuteFunction(thisArg, fnArgs); } finally { for (int i = 0; i < fnArgs.Length; i++) { if (!xraylist.Contains(i)) { fnArgs[i].Dispose(); } } } retval = CastCefV8ValueToDotnetType(target.Context, value, out bool isxray); if (!isxray) { value.Dispose(); } } finally { target.Context.Exit(); } return(retval); }