Alex Rivera | Logout

How can I change the CurrentCulture of the entire process (not just current thread) in .Net?

Asked 2009-09-22T13:12:05.993
19

I have a situation where I need to set my process' locale to en-US.

I know how to do this for the current thread:

System.Threading.Thread.CurrentThread.CurrentCulture = 
     System.Globalization.CultureInfo.CreateSpecificCulture("en-US");

But my application uses BackgroundWorkers to do some processing, and the locale for these worker threads seems not to be affected by the above change to their spawning main-thread.

So how can I set the locale for all the threads in my application without setting it in each one manually?

Edit
Report

1 Answer

13

With 4.0, you will need to manage this yourself by setting the culture for each thread. But with 4.5, you can define a culture for the appdomain and that is the preferred way to handle this. The relevant apis are CultureInfo.DefaultThreadCurrentCulture and CultureInfo.DefaultThreadCurrentUICulture.

answered 2013-02-27T18:40:55.240

Your Answer