Can you make sure all threads are started with a specific culture?
In my windows service, Spring.NET creates some threads handling jobs. Is it possible to make sure all these threads are started with a specific culture? Or do I have to set the culture in each thread?
In ASP.NET, you can set the culture (globalization tag in web.config) at application level... can this be done in Wi开发者_开发百科ndows Forms/Windows Service?
Unfortunately, there is no way to set the culture globally for all future threads. They will always have the current system culture by default. So you have to explicitly set the culture through the CurrentCulture
property (note that you can set it before you actually start the thread)
EDIT: .NET 4.5 will provide a new CultureInfo.DefaultThreadCurrentCulture
property that lets you set the default culture for all new threads in the current application domain (CultureInfo.DefaultThreadCurrentUICulture
is also available)
Yes, you can use Thread.CurrentCulture
or Application.CurrentCulture
精彩评论