ASP.NET 中的新线程在不同文化中运行

发布于 2024-10-06 20:34:06 字数 356 浏览 0 评论 0原文

我有 System.Timers.Timer 根据计划执行一些操作。当计时器上升事件时,线程区域性为“ru-RU”,与我的网络配置中的区域性不同。

<globalization culture="en-US" uiCulture="en-US" requestEncoding="utf-8" responseEncoding="utf-8" />

我根据我的区域设置推测计时器处理程序中的文化是 ru-RU。 目前我在计时器处理程序中手动将其设置为“en-US”,但我认为这不是解决问题的最佳方法。

无论如何,除了手动设置之外,是否还有另一种解决方案可以在另一个线程中具有与我的网络配置相同的区域性?

I have System.Timers.Timer that performs some operations based on schedule. When timer rises event, the threads culture is 'ru-RU' differ from culture in my web config.

<globalization culture="en-US" uiCulture="en-US" requestEncoding="utf-8" responseEncoding="utf-8" />

I guess the culture in timer handler based on my regional settings which is ru-RU.
Currently i set it manually to 'en-US' in timer handler, but i think this is not the best way to solve the problem.

In any case is there another solution to have the same culture in another thread as in my web config except setting it manually?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

花开雨落又逢春i 2024-10-13 20:34:06

这很奇怪。创建另一个线程的每个线程都将传递所有上下文,包括安全性和区域设置。

添加调试代码以在创建线程时检查Thread.CurrentThreadCultureUICulture

That is very strange. Every thread that creates another thread will pass on all the context including security and locale.

Add a debug code to check the Culture and UICulture of the Thread.CurrentThread at the time of creation of thread.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文