I develop an application which is localized, has a multilingual interface. To do this I use winform's localazible features and also language string resources. So far so good, it works perfectly.
The problem comes, when I have to try to get a localized string inside a background worker process: it can't use the current UI culture, but default instead. ResourceManager's GetString method returns the default language string, not the string by CurrentUICulture. Note, it works perfectly in the main thread, the problem is inside backgroundworker.
So, how can I get my localized strings - based on current ui culture - from language resource files in a backgroundworker thread?
Environment: .net4, c#, Visual Studio 2010.
Thanks in advance!
You need to set the Thread.CurrentCulture and Thread.CurrentUICulture properties on the background thread to match those of the foreground thread. This should be done at the start of the code that runs on the background thread.