Home
Options

Linqpad5 not using .NET 4.6 as expected?

edited May 2017
Doing async/await work in Linqpad using 4.6 .NET framework seems to differ to what the result is in Visual Studio.

The code used (provided at https://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.currentculture(v=vs.110).aspx?f=255&MSPPError=-2147217396):

void Main() { var tasks = new List<Task>(); Console.WriteLine("The current culture is {0}", Thread.CurrentThread.CurrentCulture.Name); Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-BR"); // Change the current culture to Portuguese (Brazil). Console.WriteLine("Current culture changed to {0}", Thread.CurrentThread.CurrentCulture.Name); Console.WriteLine("Application thread is thread {0}", Thread.CurrentThread.ManagedThreadId); // Launch six tasks and display their current culture. for (int ctr = 0; ctr <= 5; ctr++) { tasks.Add(Task.Run(() => { Console.WriteLine("Culture of task {0} on thread {1} is {2}", Task.CurrentId, Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.CurrentCulture.Name); })); } Task.WaitAll(tasks.ToArray()); }

The output in Linqpad:
The current culture is pt-BR
Current culture changed to pt-BR
Application thread is thread 11
Culture of task 316 on thread 6 is en-GB
Culture of task 317 on thread 6 is en-GB
Culture of task 318 on thread 6 is en-GB
Culture of task 319 on thread 6 is en-GB
Culture of task 320 on thread 9 is en-GB
Culture of task 321 on thread 6 is en-GB
The output in Visual Studio:
The current culture is en-GB
Current culture changed to pt-BR
Application thread is thread 1
Culture of task 1 on thread 3 is pt-BR
Culture of task 2 on thread 4 is pt-BR
Culture of task 3 on thread 5 is pt-BR
Culture of task 5 on thread 3 is pt-BR
Culture of task 6 on thread 6 is pt-BR
Culture of task 4 on thread 4 is pt-BR
It was a fix in .NET 4.6 to make sure async threads follow the culture of the original thread, which is what Visual Studio is doing. Linqpad doesn't seem to be following this.

This is running the latest Linqpad5 and I've confirmed the default app.config is using 4.6 however this continues to be an issue.

Has anyone else found this? Apologies for poor formatting

Comments

Sign In or Register to comment.