ASP.NET 中的新线程在不同文化中运行
我有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很奇怪。创建另一个线程的每个线程都将传递所有上下文,包括安全性和区域设置。
添加调试代码以在创建线程时检查
Thread.CurrentThread
的Culture
和UICulture
。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
andUICulture
of theThread.CurrentThread
at the time of creation of thread.