Why is the culture kept after ConfigureAwait(false)

Viewed 840

I have the following async code:

// Main system culture is English here
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("es");

WriteLine($"{Thread.CurrentThread.ManagedThreadId}:Culture:{Thread.CurrentThread.CurrentCulture}");

await Task.Delay(1).ConfigureAwait(false);

WriteLine($"{Thread.CurrentThread.ManagedThreadId}:Culture:{Thread.CurrentThread.CurrentCulture}");

The resul I expected would be to have a different thread id after the await and that new thread id having the unmodified system culture again.

This is not happening; the thread is indeed different from the previous, but the culture is somehow flowing from the previous thread.

Why is it keeping the culture if I suggested with ConfigureAwait that I don't need to keep the SynchronisationContext? It is my understanding that the culture is not stored on the ExecutionContext therefore I am not sure why this is happening.

This is a Console application.

Full example code: https://pastebin.com/raw/rE6vZ9Jm

2 Answers
Related