c# - App or Code to Suspend Resume UWP app without Visual Studio
问题描述
My question is similar to How to make UWP app to suspend and resume state, but I need an application that I can give to my QA team so that they can more easily invoke Suspend and Resume in my app.
Since Visual Studio has a "LifeCycle Events" toolbar that lets you suspend and resume your App, I figure that there must be an app that ships with Visual Studio that does this. However, perusing through the Visual Studio files, I was not able to find such an executable.
Does anyone know of a stand-alone application (installed with Visual Studio or not) that can suspend or resume a windows store app?
If not, does anyone have sample code that can suspend or resume an arbitrary UWP app? I understand that there are some C++ libraries for building a debugger, but I'm not a C++ programmer. If there's a C# way to do this, please post some code. If it must be a C++ application, please post a complete example that is easy to build.
解决方案
UWP 提供用于暂停和恢复应用的专用 API: StartSuspendAsync StartResumeAsync
例如,您可以如何暂停 FeedbackHub 应用程序:
var diag = await AppDiagnosticInfo.RequestInfoForPackageAsync("Microsoft.WindowsFeedbackHub_8wekyb3d8bbwe");
if (diag.Count > 0)
{
var resourceGroups = diag[0].GetResourceGroups();
if (resourceGroups.Count > 0)
{
await resourceGroups[0].StartSuspendAsync();
}
}
请注意,您需要声明“appDiagnostics”功能才能调用这些 API:
<Package
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
...
<Capabilities>
<rescap:Capability Name="appDiagnostics" />
</Capabilities>
</Package>
推荐阅读
- jms - Quarkus IBM MQ 扩展
- java - 显式类型转换为字节溢出
- jpos - jpos:如何处理具有不同标头和不同长度的消息,侦听相同的端点并使用相同的打包器
- python - XML 到 DateFrame Python
- mysql - 具有不同列顺序和不同 WHERE 条件的 SELECT 返回的行数多于总行数
- ios - 提供的 API 密钥已过期(对于 Directions API)
- java - 在 IntelliJ Idea 中包装方法调用
- angular - 使用ngx-mask在angula8中输入数字后如何使用ctrl + Z清除所有值
- python - 如何获取图像的 ID
- excel - 如果列标题是特定文本,则替换列中的文本