Firstly, it was not their choice. This decision was made long before they began work, and culture is a property of the operating system thread. Check out the SDK docs for the Get / SetThreadLocale () API functions, for example.
This does not fully explain this; they virtualized other OS functions, although it is very difficult to virtualize, because many APIs are culture sensitive, especially COM versions.
The next good reason is that it is very difficult to alter the process across the whole culture. This is a state of insoluble race. Some other thread may be at the center of formatting culturally similar data. While blocking will work to prevent the use of the properties of a culture as it changes, it cannot prevent it from changing in the middle of a call formatting chain. This would require them to take some kind of global lock and hold it for the duration of the formatting job. Probably a dead end.
There is another aspect of this, which I consider to be a real problem. This is due to the Thread.ExecutionContext property. The structure uses this to “stream” the state of a stream from one stream to another. Very obscure, but important to stuff things like the security context into the workflow. It would be ideal if this context could also fill the culture, so you can be sure that any of the workers you start has the same culture that you have chosen, and not the default for the operating system.
This is not so, I really do not know why. Probably because the first reason I gave. However, it is very dangerous for changing the culture of flows. The errors that can cause are very subtle. Similar to creating a SortedDictionary with a string as a key element of the main thread with a custom culture by default. Then, finding out that the workflow cannot occasionally find material back, because the rules for sorting strings are different.
EDIT: There is some relief from this problem in .NET 4.5, it supports the new static properties CultureInfo.DefaultThreadCurrentCulture and DefaultThreadCurrentUICulture.
EDIT2: The culture is now flowing as described in the 4th paragraph in .NET 4.6. This should alleviate all problems.
Hans passant
source share