Skip to content

Commit cb8308b

Browse files
committed
JavaScriptEngine is thread-safe and meant to be an app-wide singleton.
1 parent ab633ca commit cb8308b

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

build.proj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ of patent rights can be found in the PATENTS file in the same directory.
1111
<PropertyGroup>
1212
<Major>1</Major>
1313
<Minor>0</Minor>
14-
<Build>0</Build>
14+
<Build>1</Build>
1515
<Revision>0</Revision>
1616
<DevBuild>true</DevBuild>
1717
<DevNuGetServer>http://reactjs.net/packages/</DevNuGetServer>

src/React/AssemblyRegistration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ public void Register(TinyIoCContainer container)
3737
// One instance shared for the whole app
3838
container.Register<IReactSiteConfiguration>((c, o) => ReactSiteConfiguration.Configuration);
3939
container.Register<IFileCacheHash, FileCacheHash>().AsSingleton();
40+
container.Register<IJavaScriptEngineFactory, JavaScriptEngineFactory>().AsSingleton();
4041

4142
container.Register<IReactEnvironment, ReactEnvironment>().AsPerRequestSingleton();
42-
container.Register<IJavaScriptEngineFactory, JavaScriptEngineFactory>().AsPerRequestSingleton();
4343

4444
// JavaScript engines
4545
container.Register(new JavaScriptEngineFactory.Registration

src/React/ReactEnvironment.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace React
2121
/// Request-specific ReactJS.NET environment. This is unique to the individual request and is
2222
/// not shared.
2323
/// </summary>
24-
public class ReactEnvironment : IReactEnvironment
24+
public class ReactEnvironment : IReactEnvironment, IDisposable
2525
{
2626
/// <summary>
2727
/// Format string used for React component container IDs
@@ -328,5 +328,13 @@ private static string GetVersion()
328328
var build = rawVersion.Substring(lastDot + 1);
329329
return string.Format("{0} (build {1})", version, build);
330330
}
331+
332+
/// <summary>
333+
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
334+
/// </summary>
335+
public void Dispose()
336+
{
337+
_engineFactory.DisposeEngineForCurrentThread();
338+
}
331339
}
332340
}

0 commit comments

Comments
 (0)