无需Visual Studio即可暂停简历UWP应用的应用或代码 [英] App or Code to Suspend Resume UWP app without Visual Studio
问题描述
我的问题类似于如何制作UWP应用程序暂停并恢复状态,但是我需要一个可以提供给质量检查小组的应用程序,以便他们可以更轻松地在我的应用程序中调用挂起和恢复。
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.
由于Visual Studio有一个 LifeCycle Events工具栏,可让您挂起和恢复应用程序,因此我认为必须有一个随Visual Studio一起提供的应用程序可以执行此操作。但是,仔细阅读Visual Studio文件后,我找不到这样的可执行文件。
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.
有人知道一个可以暂停或恢复Windows应用商店应用程序的独立应用程序(是否安装了Visual Studio)?
Does anyone know of a stand-alone application (installed with Visual Studio or not) that can suspend or resume a windows store app?
如果没有,是否有人可以暂停或恢复任意UWP应用的示例代码?我知道有一些C ++库可用于构建调试器,但我不是C ++程序员。如果有使用C#的方法,请发布一些代码。如果它必须是C ++应用程序,请发布一个易于构建的完整示例。
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
UWP provides dedicated APIs for suspending and resuming apps: StartSuspendAsync StartResumeAsync
例如,这里是如何暂停FeedbackHub应用的方法:
Here is for example how you can suspend the FeedbackHub app:
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的功能:
Note that you will need to declare the 'appDiagnostics' capability to call these APIs:
<Package
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap mp rescap">
...
<Capabilities>
<rescap:Capability Name="appDiagnostics" />
</Capabilities>
</Package>
这篇关于无需Visual Studio即可暂停简历UWP应用的应用或代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!