Skip to content

Instantly share code, notes, and snippets.

@felipeslongo
Last active March 13, 2019 17:29
Show Gist options
  • Save felipeslongo/f10e42f25ea3ca1d949e002cda5e3ec9 to your computer and use it in GitHub Desktop.
Save felipeslongo/f10e42f25ea3ca1d949e002cda5e3ec9 to your computer and use it in GitHub Desktop.
Set CultureInfo for the entire application
using System.Threading;
namespace System.Globalization
{
public static class CultureInfo_Setters
{
public static void SetForApplication(this CultureInfo @this)
{
@this.SetForCurrentThread();
@this.SetForThreadPoolThreads();
}
public static void SetForCurrentThread(this CultureInfo @this)
{
Thread.CurrentThread.CurrentCulture = @this;
Thread.CurrentThread.CurrentUICulture = @this;
}
public static void SetForThreadPoolThreads(this CultureInfo @this)
{
CultureInfo.DefaultThreadCurrentCulture = @this;
CultureInfo.DefaultThreadCurrentUICulture = @this;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment