Exemplo n.º 1
0
        public void MappingEngineLoadErrorDuringOutOfMemoryIsCorrect()
        {
            // Arrange
            IJsEngine             jsEngine  = null;
            JsEngineLoadException exception = null;

            // Act
            try
            {
                jsEngine = new ChakraCoreJsEngine(
                    new ChakraCoreSettings
                {
                    MemoryLimit = new UIntPtr(8 * 1024)
                }
                    );
            }
            catch (JsEngineLoadException e)
            {
                exception = e;
            }
            finally
            {
                jsEngine?.Dispose();
            }

            // Assert
            Assert.NotNull(exception);
            Assert.Equal("Engine load error", exception.Category);
            Assert.Equal("Out of memory.", exception.Description);
        }
Exemplo n.º 2
0
        private void Initialize()
        {
            if (_initialized)
            {
                return;
            }

            try
            {
                _jsEngine = new ChakraCoreJsEngine();
                OnInitialize();
            }
            catch
            {
                _jsEngine?.Dispose();
                _jsEngine = null;
                throw;
            }

            _initialized = true;
        }
Exemplo n.º 3
0
        public void DisposeEngine(ChakraCoreJsEngine engine)
        {
            _engines.TryRemove(engine, out _);

            try
            {
                engine._dispatcher?.Invoke(
                    () =>
                {
                    engine._dispatcher._sharedQueue        = null;
                    engine._dispatcher._sharedQueueEnqeued = null;
                });
            }
            catch (Exception ex)
            {
                // ignored
            }

            engine.Dispose();
            _enginePopulater?.Set();
        }
Exemplo n.º 4
0
 public void Dispose()
 {
     _scriptEngine?.Dispose();
 }
Exemplo n.º 5
0
 void IDisposable.Dispose()
 {
     _jsEngine?.Dispose();
     _jsEngine = null;
 }
Exemplo n.º 6
0
 protected override void Dispose(bool disposing)
 {
     engine?.Dispose();
     base.Dispose(disposing);
 }