user2799350
user2799350

Reputation: 399

How to restart an application?

I'm going to change my app's language.

Thread.CurrentThread.CurrentCulture = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;

but the problem is that it needs the application to be restarted. Is it possible to restart the app? (or is it possible to change the language without restarting?)

Upvotes: 2

Views: 1558

Answers (2)

Tom Verhoeff
Tom Verhoeff

Reputation: 1270

It is not possible to force a restart of an application, also changing the language of a running app is pretty complicated. Here's what I would do:

  1. Default to the OSs culture (standard behavior)
  2. If required, allow the user to change the language in the app and make sure the override happens in the App.xaml.cs constructor
  3. If a user changes the language, which is a scenario that doesn't occur often, show a popup that explains that a restart of the app is required. This is an approach that I took in a few apps and users are fine with that solution. It saves the huge effort of changing language "on-the-fly"

Good luck and let us know what you ended up doing!

Upvotes: 4

user2771704
user2771704

Reputation: 6202

As far as I know you can't change the language without restart avoiding additional code in you case. There is example of how to do it without restart, but things get a little bit more complicated here.

Upvotes: 0

Related Questions