idenardi
idenardi

Reputation: 641

Change thread culture .NET Framework 4.6 and later versions

I'm trying to change a new thread CultureInfo like the sample below but:

I notice that before .net 4.6 this sample works. Did something changed in 4.6?

Thank you!

Upvotes: 0

Views: 2100

Answers (1)

idenardi
idenardi

Reputation: 641

While this odd situation has no answer (Microsoft bug report), I found a work around setting DefaultThreadCurrentCulture at the start of my code (Main method):

        var ci = new System.Globalization.CultureInfo(System.Globalization.CultureInfo.CurrentCulture.LCID);
        ci.NumberFormat.CurrencyDecimalSeparator = ".";
        ci.NumberFormat.CurrencyGroupSeparator = ",";
        ci.NumberFormat.NumberDecimalSeparator = ".";
        ci.NumberFormat.NumberGroupSeparator = ",";
        ci.NumberFormat.PercentDecimalSeparator = ".";
        ci.NumberFormat.PercentGroupSeparator = ",";
        System.Globalization.CultureInfo.DefaultThreadCurrentCulture = ci;
        System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = ci;

Upvotes: 4

Related Questions