Skip to content

Commit 22c44ed

Browse files
committed
Lock engine to prevent double use
1 parent b9c451f commit 22c44ed

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/AngleSharp.Js/EngineInstance.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,13 @@ public EngineInstance(IWindow window, IDictionary<String, Object> assignments, I
7676

7777
public JsValue RunScript(String source, JsValue context)
7878
{
79-
_engine.EnterExecutionContext(Lexicals, Variables, context);
80-
_engine.Execute(source);
81-
_engine.LeaveExecutionContext();
82-
return _engine.GetCompletionValue();
79+
lock (_engine)
80+
{
81+
_engine.EnterExecutionContext(Lexicals, Variables, context);
82+
_engine.Execute(source);
83+
_engine.LeaveExecutionContext();
84+
return _engine.GetCompletionValue();
85+
}
8386
}
8487

8588
#endregion

0 commit comments

Comments
 (0)