1. <small id='ewuVJ'></small><noframes id='ewuVJ'>

  2. <i id='ewuVJ'><tr id='ewuVJ'><dt id='ewuVJ'><q id='ewuVJ'><span id='ewuVJ'><b id='ewuVJ'><form id='ewuVJ'><ins id='ewuVJ'></ins><ul id='ewuVJ'></ul><sub id='ewuVJ'></sub></form><legend id='ewuVJ'></legend><bdo id='ewuVJ'><pre id='ewuVJ'><center id='ewuVJ'></center></pre></bdo></b><th id='ewuVJ'></th></span></q></dt></tr></i><div id='ewuVJ'><tfoot id='ewuVJ'></tfoot><dl id='ewuVJ'><fieldset id='ewuVJ'></fieldset></dl></div>
  3. <legend id='ewuVJ'><style id='ewuVJ'><dir id='ewuVJ'><q id='ewuVJ'></q></dir></style></legend>

  4. <tfoot id='ewuVJ'></tfoot>

        <bdo id='ewuVJ'></bdo><ul id='ewuVJ'></ul>

      如何在 .Net 中更改整个进程(不仅仅是当前线程

      时间:2023-08-25
      • <bdo id='6Ej4b'></bdo><ul id='6Ej4b'></ul>
          <tbody id='6Ej4b'></tbody>

      • <i id='6Ej4b'><tr id='6Ej4b'><dt id='6Ej4b'><q id='6Ej4b'><span id='6Ej4b'><b id='6Ej4b'><form id='6Ej4b'><ins id='6Ej4b'></ins><ul id='6Ej4b'></ul><sub id='6Ej4b'></sub></form><legend id='6Ej4b'></legend><bdo id='6Ej4b'><pre id='6Ej4b'><center id='6Ej4b'></center></pre></bdo></b><th id='6Ej4b'></th></span></q></dt></tr></i><div id='6Ej4b'><tfoot id='6Ej4b'></tfoot><dl id='6Ej4b'><fieldset id='6Ej4b'></fieldset></dl></div>

          <small id='6Ej4b'></small><noframes id='6Ej4b'>

        1. <legend id='6Ej4b'><style id='6Ej4b'><dir id='6Ej4b'><q id='6Ej4b'></q></dir></style></legend>
          <tfoot id='6Ej4b'></tfoot>

                本文介绍了如何在 .Net 中更改整个进程(不仅仅是当前线程)的 CurrentCulture?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我需要将进程的语言环境设置为 en-US.

                I have a situation where I need to set my process' locale to en-US.

                我知道如何为当前线程执行此操作:

                I know how to do this for the current thread:

                System.Threading.Thread.CurrentThread.CurrentCulture = 
                     System.Globalization.CultureInfo.CreateSpecificCulture("en-US");
                

                但我的应用程序使用 BackgroundWorkers 进行一些处理,并且这些工作线程的语言环境似乎不受上述对其产生的主线程的更改的影响.

                But my application uses BackgroundWorkers to do some processing, and the locale for these worker threads seems not to be affected by the above change to their spawning main-thread.

                那么如何在不手动设置每个线程的情况下为我的应用程序中的所有线程设置语言环境?

                So how can I set the locale for all the threads in my application without setting it in each one manually?

                推荐答案

                如果您想这样做,您必须更改操作系统区域设置.您希望 BackgroundWorkers 在 en-US 中运行的原因是什么?

                You'll have to change the operating system locale if you want to do that. For what reason do you want BackgroundWorkers to run in en-US?

                您的业务层应该在不变的文化中运行,并且只有最终用户的 UI 具有特定的文化.

                You should have your business layer running in an invariant culture, and only have a specific culture for the end user's UI.

                如果您使用的是 BackgroundWorker 组件,并且必须这样做,您可以在 DoWork 方法中尝试这样的操作:

                If you are using the BackgroundWorker component, and have to do this you could try something like this in the DoWork method:

                // In DoWork
                System.Globalization.CultureInfo before = System.Threading.Thread.CurrentThread.CurrentCulture;
                try
                
                {
                    System.Threading.Thread.CurrentThread.CurrentCulture = 
                        new System.Globalization.CultureInfo("en-US");
                 // Proceed with specific code
                }
                
                finally
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = before;
                }
                

                这篇关于如何在 .Net 中更改整个进程(不仅仅是当前线程)的 CurrentCulture?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 Windows Phone 上更改 C# 中的本地化? 下一篇:Javascript 日期本地化

                相关文章

                最新文章

                • <bdo id='mWyjQ'></bdo><ul id='mWyjQ'></ul>
              • <legend id='mWyjQ'><style id='mWyjQ'><dir id='mWyjQ'><q id='mWyjQ'></q></dir></style></legend>
                <i id='mWyjQ'><tr id='mWyjQ'><dt id='mWyjQ'><q id='mWyjQ'><span id='mWyjQ'><b id='mWyjQ'><form id='mWyjQ'><ins id='mWyjQ'></ins><ul id='mWyjQ'></ul><sub id='mWyjQ'></sub></form><legend id='mWyjQ'></legend><bdo id='mWyjQ'><pre id='mWyjQ'><center id='mWyjQ'></center></pre></bdo></b><th id='mWyjQ'></th></span></q></dt></tr></i><div id='mWyjQ'><tfoot id='mWyjQ'></tfoot><dl id='mWyjQ'><fieldset id='mWyjQ'></fieldset></dl></div>

                  <small id='mWyjQ'></small><noframes id='mWyjQ'>

                    <tfoot id='mWyjQ'></tfoot>