簡體   English   中英

重啟/重啟 UWP 應用

[英]Reboot/Restart an UWP app

我有一個 UWP 應用程序(在 Windows/Microsoft Store 中發布),我正在處理一個新的更新,我在我的應用程序中使用了 Template10,它有深色和淺色主題,在 Windows 10 移動版中,但為了使更改有效,用戶必須手動關閉應用程序並重新啟動它。 有沒有可能重新啟動/重新啟動我的應用程序? 也就是說,要單獨/自動關閉應用程序並自動重新打開我的應用程序?

在秋季創作者更新 (1709) 中,我們在 CoreApplication 上引入了一種名為 RequestRestart() 的新方法,它可以實現這種情況。 您將需要 16299 SDK(或更高版本)才能訪問此 API。

https://docs.microsoft.com/en-us/uwp/api/windows.applicationmodel.core.coreapplication#Methods_

這是一個博客/示例:

https://blogs.windows.com/buildingapps/2017/07/28/restart-app-programmatically/

你可以用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();  
            }  

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM