0

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? ..

user1764824
  • 9
  • 1
  • 3
  • Post your code, how else should we know what is not working... – philkark Oct 22 '12 at 11:59
  • It is normally written as `en-US` (two lower case characters, dash, two upper case characters). Not sure if that makes a difference though. – Oded Oct 22 '12 at 11:59
  • Debug it and see where it hangs. – Alex Oct 22 '12 at 12:02
  • @ Alex .. Sir once it gets Hanged I cant do anything... Form is not getting focused and nothing in form works.. Eventviewer is not showing anything. – user1764824 Oct 22 '12 at 12:06
  • @user1764824 Again: Please post your code, so others can see what might be causing the problem. – philkark Oct 22 '12 at 12:07
  • @user1764824 - Debug it while Visual Studio is running. We need more information. For instance what control panel exactly? – Security Hound Oct 22 '12 at 12:10
  • In VS when it hangs... click the "Debug" menu then choose "Break All" to find out what it is doing. This may help you. Also you could set a break point in the code that handles changing culture info and step through it a line of code at a time until you figure out why it is stuck. – John Sobolewski Oct 22 '12 at 12:22
  • Check if http://ikriv.com/dev/dotnet/MysteriousHang.html helps. – Ram Jan 11 '13 at 09:26

0 Answers0