Skip to content

CultureInfo in Dotnet Core #48077

@kurtisane

Description

@kurtisane

Hi,
I'm quite confused regarding CultureInfo, Parallesism, Scopes etc.
When a CultureInfo is set, it is set for a thread. For my understanding all Tasks that run in a Thread get the CultureInfo of the Thread they run in and when any of the Task changes the CultureInfo it is changing the CultureInfo of the whole Thread and therefore all of the Tasks. I have the assumption that scopes don't run in seperate threads and more in seperate tasks. Is that right ?
That would mean that if a scope changes the CultureInfo at any time it could effect parallel running scopes ?
Since the RequestCultureProviders also just change the CultureInfo of the current Thread could that effect across scopes ??? I'm really confused.

Example :

  1. Scope No1 (Task 1, Thread 1) gets created
  2. Scope No1 sets CultureInfo to en-US
  3. Scope No2 (Task 2, Thread 1) gets created
  4. Scope No2 sets CultureInfo to de-DE
  5. Option A : Scope No1 accesses Resource File
    Option B : Scope No1 creates multiple Tasks

What are the CultureInfos for Option A and Option B at those moments ?
How does Dotnet Core handle this ?
How does Dotnet Core seperate scopes ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.GlobalizationquestionAnswer questions and provide assistance, not an issue with source code or documentation.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions