How to open a form in a separate thread due to language requirements

I am using .NET 4.0. All my forms are localized and translated into 3 languages. I would like to open my main form, the one that we run in program.cs, as a login form with a language button. When a language is selected, since I cannot change the culture information of the current thread, I would like to open a new thread in the requested culture. What is the easiest way to do this?

thanks

+4
source share
3 answers
Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-ca"); 
+6
source

Do not do this; it cannot work reliably by design. The first obvious drawback that you will encounter is that all Windows dialogs will not change their language (MessageBox, OpenFileDialog, etc.). They always use the system language. Much more serious are the unobvious flaws. You cannot easily control the culture of any threads, especially threadpool threads. They will do something unpleasant, like populating a SortedList, a list that is no longer sorted in the UI thread. Many other subtle issues like this.

It is also a feature that never needs a single user. They do not switch their native language on the fly. If the machine is really used by multilingual users, then it will have a version of Windows that allows you to switch the system language. Your application automatically follows suit.

+3
source

MyThread.CurrentUICulture = value; You can read it here.

+1
source

Source: https://habr.com/ru/post/1337373/


All Articles