CurrentCulture and CurrentIUCulture

Release 1.0 - ...

Two properties determine the default internationalization behavior of an application, which are: CurrentCulture and CurrentUICulture. Both properties can be accessed either from the current thread or from the CultureInfo class, but they can be assigned only from the current thread.

CurrentCulture represents the default culture for all classes in System.Globalization and thus affects issues such as culture-specific formatting (such as date/time and number/currency formats), parsing, and sorting. CurrentCulture defaults to the Win32 function GetUserDefaultLCID. This value is set in the Regional and Language Options Control Panel applet. Bear in mind that the CurrentCulture is culture-specific, not culture-neutral. That is, the value includes a region as well as a language.

CurrentUICulture represents the default culture used by ResourceManager methods and thus affects the retrieval of user interface resources such as strings and bitmaps. The CurrentUICulture defaults to the Win32 function GetUserDefaultUILanguage. This value is usually determined by the user interface language version of the operating system and cannot be changed.

Each thread must have its CurrentCulture and CurrentUICulture properties explicitly and manually set. If you create your own threads, you must set these properties in code. The important point to grasp here is that new threads do not automatically "inherit" these values from the thread from which they were created; a new thread is completely new and needs to be reminded of these values. To create a new thread, you could write this:

Smartsite SXML CopyCode image Copy Code
Thread thread = new Thread(new ThreadStart(Work));
thread.CurrentCulture = Thread.CurrentThread.CurrentCulture;
thread.CurrentUICulture = Thread.CurrentThread.CurrentUICulture;
thread.Start();