Can you make sure all threads are running with a specific culture?

In my Windows service, Spring.NET creates some thread processing tasks. Is it possible to make sure that all these flows are launched with a certain culture? Or do I need to establish a culture in each thread?

In ASP.NET you can set the culture (globalization tag in web.config) at the application level ... can this be done in Windows Forms / Windows Service?

+3
source share
2 answers

Unfortunately, there is no way to establish a culture globally for all future flows. By default, they will always have the current system culture. Therefore, you must explicitly set the culture using the property CurrentCulture(note that you can set it before the start of the stream)


EDIT: ..NET 4.5 will provide a new property CultureInfo.DefaultThreadCurrentCulturethat allows you to set a default culture for all new threads in the current application domain ( CultureInfo.DefaultThreadCurrentUICulturealso available)

+5
source

Yes you can use Thread.CurrentCulture

or Application.CurrentCulture

0
source

Source: https://habr.com/ru/post/1768945/


All Articles