views:

691

answers:

1

I am experiencing some weird behavior with localized messages reported from my background worker process in my windows forms application.

The application is a setup application with windows forms. The application launches a background worker to perform and IIS reset and then install MSIs.

The first time I run the application on a Spanish Win Server 2003 VM the forms are in spanish but not the BWP messages. If i immediately run it again, the messages are in spanish.

The .Resources files are embedded resources and are extracted to the temp directory upon application startup.

My code retrieves the localized strings through a custom resource manager class. This class creates a file based resource to the .Resources files in the temp directory. This is working correctly because the windows forms labels and title are localized every time.

Has anyone experienced this? I'm absolutely stuck, please help. Thanks, Andrew

+1  A: 

The culture info is in thread-local storage, so if the background worker runs processes on different threads, this may be expected.

http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.currentculture.aspx

http://msdn.microsoft.com/en-us/library/system.threading.thread.currentculture.aspx

I am not sure what the recommended practice for transfering culture info across threads, though.

Brian