MsieJavaScriptEngine.JsRt.Edge.EdgeJsRuntime.CreateContext C# (CSharp) Method

CreateContext() public method

Creates a debug script context for running scripts
Each script context has its own global object that is isolated from all other script contexts.
public CreateContext ( ) : EdgeJsContext
return EdgeJsContext
        public EdgeJsContext CreateContext()
        {
            EdgeJsContext reference;
            EdgeJsErrorHelpers.ThrowIfError(EdgeNativeMethods.JsCreateContext(this, out reference));

            return reference;
        }

Usage Example

コード例 #1
0
        /// <summary>
        /// Constructs an instance of the Chakra “Edge” JsRT engine
        /// </summary>
        /// <param name="enableDebugging">Flag for whether to enable script debugging features</param>
        public ChakraEdgeJsRtJsEngine(bool enableDebugging)
            : base(JsEngineMode.ChakraEdgeJsRt, enableDebugging)
        {
            _dispatcher.Invoke(() =>
            {
                try
                {
                    _jsRuntime = CreateJsRuntime();
                    _jsContext = _jsRuntime.CreateContext();
                }
                catch (JsUsageException e)
                {
                    string errorMessage;
                    if (e.ErrorCode == JsErrorCode.WrongThread)
                    {
                        errorMessage = CommonStrings.Runtime_JsEnginesConflictOnMachine;
                    }
                    else
                    {
                        errorMessage = string.Format(CommonStrings.Runtime_EdgeJsEngineNotLoaded, e.Message);
                    }

                    throw new JsEngineLoadException(errorMessage, _engineModeName);
                }
                catch (Exception e)
                {
                    throw new JsEngineLoadException(
                        string.Format(CommonStrings.Runtime_EdgeJsEngineNotLoaded, e.Message), _engineModeName);
                }
            });
        }