public static void Invoke(Action <IV8SplitProxyNative> action) { var previousScheduledException = MiscHelpers.Exchange(ref V8SplitProxyManaged.ScheduledException, null); try { action(instance); ThrowScheduledException(); } finally { V8SplitProxyManaged.ScheduledException = previousScheduledException; } }
public static T Invoke <T>(Func <IV8SplitProxyNative, T> func) { var previousScheduledException = MiscHelpers.Exchange(ref V8SplitProxyManaged.ScheduledException, null); try { var result = func(instance); ThrowScheduledException(); return(result); } finally { V8SplitProxyManaged.ScheduledException = previousScheduledException; } }
internal override object Execute(string documentName, string code, bool evaluate, bool discard) { VerifyNotDisposed(); return(ScriptInvoke(() => { var uniqueName = documentNameManager.GetUniqueName(documentName, "Script Document"); if (discard) { uniqueName += " [temp]"; } else if (documentNames != null) { documentNames.Add(uniqueName); } if (inContinuationTimerScope || (ContinuationCallback == null)) { if (MiscHelpers.Exchange(ref awaitDebuggerAndPause, false)) { proxy.AwaitDebuggerAndPause(); } return proxy.Execute(uniqueName, FormatCode ? MiscHelpers.FormatCode(code) : code, evaluate, discard); } var state = new Timer[] { null }; using (state[0] = new Timer(unused => OnContinuationTimer(state[0]), null, Timeout.Infinite, Timeout.Infinite)) { inContinuationTimerScope = true; try { state[0].Change(continuationInterval, Timeout.Infinite); if (MiscHelpers.Exchange(ref awaitDebuggerAndPause, false)) { proxy.AwaitDebuggerAndPause(); } return proxy.Execute(uniqueName, FormatCode ? MiscHelpers.FormatCode(code) : code, evaluate, discard); } finally { inContinuationTimerScope = false; } } })); }
// ReSharper disable ParameterHidesMember private object Execute(V8Script script, bool evaluate) { MiscHelpers.VerifyNonNullArgument(script, "script"); VerifyNotDisposed(); return(MarshalToHost(ScriptInvoke(() => { if (inContinuationTimerScope || (ContinuationCallback == null)) { if (MiscHelpers.Exchange(ref awaitDebuggerAndPause, false)) { proxy.AwaitDebuggerAndPause(); } return proxy.Execute(script, evaluate); } var state = new Timer[] { null }; using (state[0] = new Timer(unused => OnContinuationTimer(state[0]), null, Timeout.Infinite, Timeout.Infinite)) { inContinuationTimerScope = true; try { state[0].Change(continuationInterval, Timeout.Infinite); if (MiscHelpers.Exchange(ref awaitDebuggerAndPause, false)) { proxy.AwaitDebuggerAndPause(); } return proxy.Execute(script, evaluate); } finally { inContinuationTimerScope = false; } } }), false)); }