为什么不能设置Thread.CurrentThread.CurrentCulture?

问题描述 投票:1回答:1

我有一个WCF服务,在其中设置CurrentCulture和CurrentUICulture以确保我的资源正确地本地化。有时它似乎有效,但有时将其设置似乎被忽略。

enter image description here

正如您在这里看到的那样,分配了值“ de-DE”,但是线程的CurrentCulture似乎忽略了它。

c# .net multithreading cultureinfo
1个回答
0
投票

CurrentUICulture属性与任何其他属性一起使用时均无法可靠地工作当前线程以外的其他线程。在.NET Framework中,请阅读该属性是可靠的,尽管将其设置为除当前线程不是。

您可以尝试使用DefaultThreadCurrentCulture 设置当前应用程序域中线程的默认区域性

CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture;

© www.soinside.com 2019 - 2024. All rights reserved.