Application hangs after changing language From “En-Us” to any global language in control panel

Posted by user1764824 on Stack Overflow See other posts from Stack Overflow or by user1764824
Published on 2012-10-22T11:57:51Z Indexed on 2012/10/25 5:02 UTC
Read the original article Hit count: 504

Filed under:
|
|

I created a WinForms application using C#. When I try to change the culture info, my application gets hanged.

                Microsoft.Win32.SystemEvents.UserPreferenceChanged += new 
               Microsoft.Win32.UserPreferenceChangedEventHandler(SystemEvents_UserPreferenceChanged);

        void SystemEvents_UserPreferenceChanged(object sender, Microsoft.Win32.UserPreferenceChangedEventArgs e)
    {
        if (!PreviousInstance())
        {
            CultureInfo ObjCulture = new CultureInfo(CultureInfo.InvariantCulture.IetfLanguageTag, false);
            Thread.CurrentThread.CurrentCulture = ObjCulture;
            Application.CurrentCulture = ObjCulture;

        }
    }

        public void INIT()
        {
        CultureInfo objCultureInfo = null;
        try
        {
        objCultureInfo = new CultureInfo("en-US", false);
            objCultureInfo.NumberFormat.NumberDecimalSeparator = ".";
            objCultureInfo.NumberFormat.NegativeSign = "-";
            objCultureInfo.NumberFormat.NumberNegativePattern = 1; //1 stands for -100.
            Application.CurrentCulture = objCultureInfo;
        }
        }

After Changing Language ... My Application gets Hanged and i cant Debug anything When i Try to Evaluate things This Event Called only once.. But if try in a small application it comes every time when Language is changed... ... Nothing shown in Eventviewer either. How can I solve this problem? ..

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms