Skip to content

Commit f95e5e1

Browse files
committed
1. Fixed a error that caused a crash during finalization;
2. In JsRT modes during calling of the `CollectGarbage` method is again not performed blocking.
1 parent 5a4cfaa commit f95e5e1

File tree

8 files changed

+469
-281
lines changed

8 files changed

+469
-281
lines changed

src/MsieJavaScriptEngine/JsRt/Edge/ChakraEdgeJsRtJsEngine.cs

Lines changed: 165 additions & 130 deletions
Large diffs are not rendered by default.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
using System;
2+
3+
namespace MsieJavaScriptEngine.JsRt.Edge
4+
{
5+
/// <summary>
6+
/// “Edge” scope automatically sets a context to current and resets the original context
7+
/// when disposed
8+
/// </summary>
9+
internal struct EdgeJsScope : IDisposable
10+
{
11+
/// <summary>
12+
/// The previous context
13+
/// </summary>
14+
private readonly EdgeJsContext _previousContext;
15+
16+
/// <summary>
17+
/// Whether the structure has been disposed
18+
/// </summary>
19+
private bool _disposed;
20+
21+
22+
/// <summary>
23+
/// Initializes a new instance of the <see cref="EdgeJsScope"/> struct
24+
/// </summary>
25+
/// <param name="context">The context to create the scope for</param>
26+
public EdgeJsScope(EdgeJsContext context)
27+
{
28+
_disposed = false;
29+
_previousContext = EdgeJsContext.Current;
30+
EdgeJsContext.Current = context;
31+
}
32+
33+
#region IDisposable implementation
34+
35+
/// <summary>
36+
/// Disposes the scope and sets the previous context to current
37+
/// </summary>
38+
public void Dispose()
39+
{
40+
if (_disposed)
41+
{
42+
return;
43+
}
44+
45+
EdgeJsContext.Current = _previousContext;
46+
_disposed = true;
47+
}
48+
49+
#endregion
50+
}
51+
}

0 commit comments

Comments
 (0)