currentculture

Does changing the culture of a threadpool thread affect it when it gets returned back to the pool?

谁说我不能喝 提交于 2019-11-29 14:05:00
If I set the CurrentCulture of a thread pool thread, what happens when the thread finishes execution and gets returned back to the thread pool? Does it get its CurrentCulture reset back to the default (whatever that may mean), or will it retain the culture I have set on it? I'm hoping that the framework resets the thread to a default state to guard against this, but cannot find any documentation to this effect. The closest I have found is from the MSDN docs for ThreadPool : When the thread pool reuses a thread, it does not clear the data in thread local storage or in fields that are marked

When should I specify CurrentCulture or InvariantCulture and when should I leave it unspecified?

拟墨画扇 提交于 2019-11-29 11:16:52
问题 What is the best practice for specifying CurrentCulture or InvariantCulture and not specifying the culture at all? From what I have read, if you're doing serialization, for instance, you need InvariantCulture as a means of specifying a canonical representation of a data value. That's a relatively small percentage of culture-based string manipulations. I find it long, verbose, and ugly most of the time to specify it every time I do, say: var greeting = string.Format(CultureInfo.CurrentCulture,

C# doubles show comma instead of period

烈酒焚心 提交于 2019-11-29 09:50:27
I almost have the same problem as the guy in this thread: Convert Float that has period instead of comma? So that my double x = 234.4; string y = x.ToString(); I get y == "234,4" ; Even worse ... Double.Parse("234.4") throws an exception. I have written alot of code before I was asked to use period instead of comma, so I would prefer to have some way to change my CultureInfo at a global level . Is there some setting in the projects that I can do? I've tried: Application.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US"); Thread.CurrentThread.CurrentCulture = CultureInfo

Does changing the culture of a threadpool thread affect it when it gets returned back to the pool?

人走茶凉 提交于 2019-11-28 07:33:33
问题 If I set the CurrentCulture of a thread pool thread, what happens when the thread finishes execution and gets returned back to the thread pool? Does it get its CurrentCulture reset back to the default (whatever that may mean), or will it retain the culture I have set on it? I'm hoping that the framework resets the thread to a default state to guard against this, but cannot find any documentation to this effect. The closest I have found is from the MSDN docs for ThreadPool: When the thread

Get current language in CultureInfo

泪湿孤枕 提交于 2019-11-27 21:47:32
How to identify the operating system's language using CultureInfo ? E.g. if the language in Windows is set to French, I need to identify French and load the fr resource files data. I think something like this would give you the current CultureInfo: CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; Is that what you're looking for? This is what i used: var culture = System.Globalization.CultureInfo.CurrentCulture; and it's working :) Current system language is retrieved using : CultureInfo.InstalledUICulture "Gets the CultureInfo that represents the culture installed with the

Best way to parse float?

一曲冷凌霜 提交于 2019-11-27 12:19:11
What is the best way to parse a float in CSharp? I know about TryParse, but what I'm particularly wondering about is dots, commas etc. I'm having problems with my website. On my dev server, the ',' is for decimals, the '.' for separator. On the prod server though, it is the other way round. How can I best capture this? Depends where the input is coming from. If your input comes from the user, you should use the CultureInfo the user/page is using ( Thread.CurrentThread.CurrentUICulture ). You can get and indication of the culture of the user, by looking at the HttpRequest.UserLanguages property

WinRT apps and Regional settings. The correct way to format dates and numbers based on the user's regional settings?

落爺英雄遲暮 提交于 2019-11-27 11:08:54
I'm having some problems in Windows 8 Metro apps (XAML & C#) regarding the user's regional settings. It seems that the apps won't respect user's regional settings , so even if your Windows 8 is set to display dates and times in Finnish format, the apps will still display them using US-formatting. But this is such a big problem that there must be something I'm missing? To test this I started by creating a WPF-application . The application just prints out the CurrentCulture and the formatted DateTime.Now: private void Culture_Loaded_1(object sender, RoutedEventArgs e) { this.Culture.Text =

Get current language in CultureInfo

 ̄綄美尐妖づ 提交于 2019-11-26 20:51:21
问题 How to identify the operating system's language using CultureInfo ? E.g. if the language in Windows is set to French, I need to identify French and load the fr resource files data. 回答1: I think something like this would give you the current CultureInfo: CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture; Is that what you're looking for? 回答2: This is what i used: var culture = System.Globalization.CultureInfo.CurrentCulture; and it's working :) 回答3: Current system language is

WinRT apps and Regional settings. The correct way to format dates and numbers based on the user's regional settings?

≡放荡痞女 提交于 2019-11-26 15:26:45
问题 I'm having some problems in Windows 8 Metro apps (XAML & C#) regarding the user's regional settings. It seems that the apps won't respect user's regional settings , so even if your Windows 8 is set to display dates and times in Finnish format, the apps will still display them using US-formatting. But this is such a big problem that there must be something I'm missing? To test this I started by creating a WPF-application . The application just prints out the CurrentCulture and the formatted