I am writing a WPF app and am having some difficulty with cultures.
I'd like to know where .NET applications pick up the value for CurrentThread.CurrentCulture when no value is explicitly set. It's not from the Windows culture info because I have changed that from en-US to en-GB without noticing any change in the application when running.
Please help!
Mark
From the fine manual:
See the
CultureInfo.CurrentCulture
property to learn how a thread's default culture is determined, and how users set culture information for their computers.
One laborious click later...
How a Thread's Culture Is Determined
When a thread is started, its culture is initially determined as follows:
By retrieving the culture that is specified by the
DefaultThreadCurrentCulture
property in the application domain in which the thread is executing, if the property value is notnull
.By calling the Windows
GetUserDefaultLocaleName
function.Note that if you set a specific culture that is different from the system-installed culture or the user's preferred culture, and your application starts multiple threads, the current culture of those threads will be the culture that is returned by the
GetUserDefaultLocaleName
function, unless you assign a culture to theDefaultThreadCurrentCulture
property in the application domain in which the thread is executing.For more information about how the culture of a thread is determined, see the "Culture and Threads" section in the
CultureInfo
topic.
I didn't budget for another click, but clicked anyway.
Culture and Threads
When a new application thread is started, its current culture and current UI culture are defined by the current system culture, and not by the current thread culture. The following example illustrates the difference. It sets the current culture and current UI culture of an application thread to the French (France) culture (fr-FR). If the current culture is already fr-FR, the example sets it to the English (United States) culture (en-US). It displays three random numbers as currency values and then creates a new thread, which, in turn, displays three more random numbers as currency values. But as the output from the example shows, the currency values displayed by the new thread do not reflect the formatting conventions of the French (France) culture, unlike the output from the main application thread.
Note that it says when a new application thread is started. So, given that you say:
It's not from the Windows culture info because I have changed that from en-US to en-GB without noticing any change in the application when running.
You might want to review this answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With