views:

25

answers:

2

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 Windows Forms/Windows Service?

A: 

Yes, you can use Thread.CurrentCulture

or Application.CurrentCulture

DrakeVN
`Thread.CurrentCulture` will only work for the specific thread. `Application.CurrentCulture` is (1) WinForms only, and (2) just a shortcut to `Thread.CurrentThread.CurrentCulture`: from the [docs](http://msdn.microsoft.com/en-us/library/system.windows.forms.application.currentculture.aspx): "A CultureInfo representing the culture information for the current thread."
Richard
+1  A: 

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)

Thomas Levesque
This, of course, also applies to threads you don't explicitly create (worker threads for other components, finalizer, and the thread pool).
Richard
Very annoying that you can't set the culture globally for future threads.
Lieven Cardoen