dotnet / dotnet/dotnet-api-docs
Documentation about the default culture of new threads is outdated
- Dominant language
- C#
- Stars
- 949
- Forks
- 1.7k
- Avg merge
- 3d 27m
- Merged PRs (30d)
- 49
Description
On the API documentation page of [CultureInfo.DefaultThreadCurrentCulture](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.defaultthreadcurrentculture?view=netframework-4.8) there is a sample that outputs the culture which is used by new threads by default. I've ran this sample on my machine and couldn't get the documented output when I used a recent target framework. Specifically, the documented output of the first sample and this sentence below it is wrong:
> However, because the worker thread's culture is derived from the current Windows system culture rather than the application's current culture, the work thread displays its currency values using the formatting conventions of the English (United States) culture.
Here are my test results:
- Runtime 4.8, target framework 4.5.2 (or lower): Documentation is correct
- Runtime 4.8, target framework 4.6-4.8: Documentation is wrong
- .NET Core 2.0-3.0: Documentation is wrong
With "Documentation is wrong" I always mean that the started worker thread **does** use the same culture as the main thread. For example, this is the output I get:
```
Current Culture: fr-FR
Current UI Culture: fr-FR
Random Values: 0,08 € 0,34 € 0,99 €
Current Culture: fr-FR
Current UI Culture: fr-FR
Random Values: 0,88 € 0,21 € 0,75 €
```
There are quite a few pages that claim that the default culture of new threads is the Windows culture, so all those need to be updated:
- [CultureInfo](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=netframework-4.8)
- [CultureInfo.DefaultThreadCurrentCulture](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.defaultthreadcurrentculture?view=netframework-4.8)
- [CultureInfo.DefaultThreadCurrentUICulture](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.defaultthreadcurrentuiculture?view=netframework-4.8)
- [CultureInfo.CurrentCulture](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.currentculture?view=netframework-4.8)
- [CultureInfo.CurrentUICulture](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.currentuiculture?view=netframework-4.8)
- [Thread](https://docs.microsoft.com/en-us/dotnet/api/system.threading.thread?view=netframework-4.8)
(There are most likely even more.)
Note: Some of those pages already mention that task-based asynchronous operations flow the culture. But as my tests show, this is also true for "normal" threads.
Contributor guide
Assessment
This issue has not been assessed yet.