BackgroundWorker culture

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mecena
    New Member
    • Apr 2007
    • 31

    BackgroundWorker culture

    Hi all!

    Anyone ever tried initializing form resources inside BackgroundWorke r's DoWork() method? Problem is that it's thread's culture is set to neutral by default. How can I change that?

    M.
  • gehho
    New Member
    • Feb 2009
    • 1

    #2
    I know this might be a bit late for you, but it might be useful for other users...

    I also ran into that problem. Now I simply changed the current thread's culture within the DoWork() method. The first statement in your DoWork() method should be something like this:

    Code:
    private void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
    {
    	System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("en-US");
    
    	// do your work here...
    }
    If you want your background worker thread to use the same culture as your main thread, you could access the application's culture using

    Code:
    System.Windows.Forms.Application.CurrentCulture
    or you just provide it as an argument to the worker.

    gehho.

    Comment

    Working...