[Mono-bugs] [Bug 378892] New: Getting a thread' s current culture while setting another thread's current culture doesn' t work.

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Apr 10 14:44:33 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=378892


           Summary: Getting a thread's current culture while setting another
                    thread's current culture doesn't work.
           Product: Mono: Runtime
           Version: 1.9.0
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: misc
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: jonathan.gagnon at croesus.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Created an attachment (id=207286)
 --> (https://bugzilla.novell.com/attachment.cgi?id=207286)
Example that reproduces the problem.

The return value of Thread.CurrentThread.CurrentCulture while setting the
culture of another thread is not always correct.

Here's an simple example that reproduces the problem :

class Program
{
        static void Main(string[] args)
        {
                for (int i = 0; i < 1000; ++i)
                {
                        Thread thread = new Thread(Test);
                        thread.CurrentCulture = new CultureInfo("en-CA");
                        thread.Start();
                }
        }

        static void Test()
        {
                string name = Thread.CurrentThread.CurrentCulture.Name;
                if (name != "en-CA")
                {
                        Console.WriteLine("Culture name : " + name);
                }
        }
}

In the main method, I create a thread, I set its current culture to "en-CA"
before starting it.  In the test method, I print the culture name if it is
different than "en-CA".  I would expect that it would never be different, but
unfortunately, every once in a while, the name is blank ("").

This problem only happens when one thread is setting the CurrentCulture of a
thread.  If I put a sleep in the for loop after the thread.Start() instruction,
this problem doesn't occur, which shows that this is a concurrency problem.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list