extendedExecutionSession:我们可以运行UWP之类的桌面应用而无需暂停吗?

Kaz*_*ama 2 c# suspend uwp

我计划启动一个UWP应用程序,监视传感器数据365天并将所有数据保存到数据库(Sqlite).

我仍然担心UWP能力.请指教我应该使用哪种(UWP/WPF)?我想使用更好的UI,我想尽可能使用UWP ......

UWP-Suspending是我的担心.

有了这篇文章,有人说了一种阻止UWP应用程序暂停的方法.

var extendedExecutionSession = new ExtendedExecutionSession();
extendedExecutionSession.Reason = ExtendedExecutionReason.Unspecified;
var extendedExecutionResult = await         extendedExecutionSession.RequestExtensionAsync();
if (extendedExecutionResult != ExtendedExecutionResult.Allowed)
{
//extended execution session revoked
     extendedExecutionSession.Dispose();
     extendedExecutionSession = null;
}
Run Code Online (Sandbox Code Playgroud)

如果我在UWP应用程序中编写此代码,我可以使用像桌面WPF应用程序这样的UWP应用程序吗?我想运行我的UWP应用程序365天而不停止..即使用户在桌面上"最小化"...请建议...

Ste*_*SFT 7

是的,您可以使用ExtendedExecution执行此操作.需要注意的一点是,当您使用电池(例如笔记本电脑,平板电脑)运行时,您将在一段时间后暂停 - 但是您也可以通过进入电池设置页面并将应用程序设置为"始终允许"来阻止它.

详细信息请记录在这里:https://docs.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution