public override void Dispose()
        {
            if (_disposedFlag.Set())
            {
                lock (_executionSynchronizer)
                {
                    if (_jsContext != null)
                    {
                        _jsContext.Dispose();
                        _jsContext = null;
                    }

                    if (_jsEngine != null)
                    {
                        _jsEngine.Dispose();
                        _jsEngine = null;
                    }

                    if (_hostItems != null)
                    {
                        _hostItems.Clear();
                    }
                }
            }
        }
        /// <summary>
        /// Constructs an instance of adapter for the Vroom JS engine
        /// (cross-platform bridge to the V8 JS engine)
        /// </summary>
        /// <param name="settings">Settings of the Vroom JS engine</param>
        public VroomJsEngine(VroomSettings settings)
        {
            VroomSettings vroomSettings = settings ?? new VroomSettings();

            try
            {
                _jsEngine = new OriginalJsEngine(vroomSettings.MaxYoungSpaceSize,
                                                 vroomSettings.MaxOldSpaceSize);
                _jsContext = _jsEngine.CreateContext();
            }
            catch (Exception e)
            {
                throw new JsEngineLoadException(
                          string.Format(CoreStrings.Runtime_JsEngineNotLoaded,
                                        EngineName, e.Message), EngineName, EngineVersion, e);
            }
        }
        /// <summary>
        /// Constructs an instance of adapter for the Vroom JS engine
        /// (cross-platform bridge to the V8 JS engine)
        /// </summary>
        /// <param name="settings">Settings of the Vroom JS engine</param>
        public VroomJsEngine(VroomSettings settings)
        {
            Initialize();

            VroomSettings vroomSettings = settings ?? new VroomSettings();

            try
            {
                _jsEngine  = new OriginalEngine(vroomSettings.MaxYoungSpaceSize, vroomSettings.MaxOldSpaceSize);
                _jsContext = _jsEngine.CreateContext();
            }
            catch (TypeInitializationException e)
            {
                Exception innerException = e.InnerException;
                if (innerException != null)
                {
                    var dllNotFoundException = innerException as DllNotFoundException;
                    if (dllNotFoundException != null)
                    {
                        throw WrapDllNotFoundException(dllNotFoundException);
                    }
                    else
                    {
                        throw JsErrorHelpers.WrapEngineLoadException(innerException, EngineName, EngineVersion,
                                                                     true);
                    }
                }

                throw JsErrorHelpers.WrapEngineLoadException(e, EngineName, EngineVersion, true);
            }
            catch (Exception e)
            {
                throw JsErrorHelpers.WrapEngineLoadException(e, EngineName, EngineVersion, true);
            }
            finally
            {
                if (_jsContext == null)
                {
                    Dispose();
                }
            }
        }