In our ASP.NET MVC 5 project we set the Culture of the main thread based on the value of a cookie so that the full Request is run under the same culture.
We'd like to start using the Async support. If we set the DefaultThreadCurrentCulture when the Request starts, will this cause all threads on this, and only this, Request to run as the defined culture?
The site gets a lot of traffic so I am worried that if I use DefaultThreadCurrentCulture that it will affect other user's as their Requests come in at the same instant.
My BaseController
{
protected override IAsyncResult BeginExecuteCore(AsyncCallback callback, object state)
{
string defaultCulture = "fr-CA"; //From Cookie in reality
// Modify current thread's cultures
Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(cultureName);
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.DefaultThreadCurrentCulture= Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.DefaultThreadCurrentUICulture= Thread.CurrentThread.CurrentCulture;
return base.BeginExecuteCore(callback, state);
}
}