Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to restart an app in UWP?

Currently in my UWP application, I provide a way to change the app theme. But in order for the change to be effective, the user has to manually close the app and restart it. I'm looking for a way to do it automatically, ie, restart the app programmatically.

Is it even possible? thank you.

like image 395
Junpei Kun Avatar asked Sep 16 '16 18:09

Junpei Kun


2 Answers

According to a recent blog post, there is a new API for this "from Build 16226 onwards, along with the corresponding SDK."

The new static RequestRestartAsync(String) method and overloads on CoreApplication provide the previously unavailable app restart magic, including the ability to pass arguments to the new instance.

like image 175
tiwahu Avatar answered Oct 04 '22 17:10

tiwahu


As far as I know there is no way for a UWP app to close itself so that means you cannot restart the app. Looks like you can close an app by using `App.Current.Exit()' but still no way to restart afterwards.

I would actually be looking at why do you need to restart when changing theme. With the way the theming systems is built it should be possible to change everything dynamically. But that might be food for a different question

like image 25
AlexDrenea Avatar answered Oct 04 '22 15:10

AlexDrenea