private JavaScriptRuntime CreateRuntime(JavaScriptRuntimeAttributes attributes)
        {
            JavaScriptRuntime runtime;

            try
            {
                // Create a runtime.
                JavaScriptErrorCode errorCode = Native.JsCreateRuntime(attributes, null, out runtime);

                if (errorCode != JavaScriptErrorCode.NoError)
                {
                    string errorMessage = string.Format("Failed to create javascript runtime with error [{0}]", errorCode);

                    System.Diagnostics.Debug.WriteLine(errorMessage);

                    throw new Exception(errorMessage);
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("An exception occurred when creating the javascript runtime with error [{0}]", ex.Message);

                throw;
            }

            return(runtime);
        }
예제 #2
0
        /// <summary>
        ///     Creates a new runtime.
        /// </summary>
        /// <param name="attributes">The attributes of the runtime to be created.</param>
        /// <param name="threadServiceCallback">The thread service for the runtime. Can be null.</param>
        /// <returns>The runtime created.</returns>
        public static JavaScriptRuntime Create(JavaScriptRuntimeAttributes attributes, JavaScriptThreadServiceCallback threadServiceCallback)
        {
            JavaScriptRuntime handle;

            Native.ThrowIfError(Native.JsCreateRuntime(attributes, threadServiceCallback, out handle));
            return(handle);
        }