18

Possible Duplicate:
Setting CurrentCulture and CurrentUICulture of an application

I want to set a default culture for every thread that i open in my application. Is there a way to set it (without setting it on every thread individually)

Thanks

Community
  • 1
  • 1
Amir Yonatan
  • 717
  • 1
  • 7
  • 14

2 Answers2

35

if you are using .net 4.5 you can use the below property

CultureInfo.DefaultThreadCurrentCulture Property

In the .NET Framework 4 and previous versions, by default, the culture of all threads is set to the Windows system culture. For applications whose current culture differs from the default system culture, this behavior is often undesirable. In the .NET Framework 4.5, the DefaultThreadCurrentCulture property enables an application to define the default culture of all threads in an application domain.

http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.defaultthreadcurrentculture.aspx

Massimiliano Peluso
  • 26,379
  • 6
  • 61
  • 70
  • Any idea how this affects IIS threads in w3wp? If each user thread has a different culture, can each of those have a default culture for new sub-threads that get spawned? – JLo Mar 19 '18 at 12:37
5

You could create a static helper class that constructs your threads with the default culture if your choice, if you are not using .NET 4.5.

ajawad987
  • 4,439
  • 2
  • 28
  • 45