I have an UWP app (published in Windows/Microsoft Store), and I am working in a new update, and I use Template10 in my app, that has dark and light theme, and in Windows 10 Mobile but for the change to be effective, the user has to manually close the app and restart it. Is there any possibility to restart/reboot my application? That is, to close the application alone/automatically and reopen my application automatically?
Asked
Active
Viewed 5,474 times
16
-
1Possible duplicate of [How to restart an app in UWP?](https://stackoverflow.com/questions/39537904/how-to-restart-an-app-in-uwp) – DogeAmazed Oct 30 '17 at 19:33
2 Answers
16
With the Fall Creators Update (1709) We have introduced a new method on CoreApplication called RequestRestart() that enables this scenario. You will need the 16299 SDK (or later) to access this API.
https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.core.coreapplication#Methods_
Here is a blog/sample:
https://blogs.windows.com/buildingapps/2017/07/28/restart-app-programmatically/

Stefan Wick MSFT
- 13,600
- 1
- 32
- 51
-
I can only use this `RequestRestart()` option if the users of my app are in 1709 or higher, right? – Fernando Sousa Nov 02 '17 at 19:40
-
@FernandoSousa for versions before 1709, I send a "restart app" toast notification and then immediately exit via `App.Current.Exit();`. Makes it easy for users to restart the app. – tiwahu Mar 15 '18 at 16:46
2
You can do this with CoreApplication.RequestRestart
var result = await CoreApplication.RequestRestartAsync("Application Restart Programmatically ");
if (result == AppRestartFailureReason.NotInForeground ||
result == AppRestartFailureReason.RestartPending ||
result == AppRestartFailureReason.Other)
{
var msgBox = new MessageDialog("Restart Failed", result.ToString());
await msgBox.ShowAsync();
}

Luca Ziegler
- 3,236
- 1
- 22
- 39