Windows 8 Metro/沉浸式应用程序-强制终止 [英] Windows 8 Metro/Immersive App - Force Terminate

查看:75
本文介绍了Windows 8 Metro/沉浸式应用程序-强制终止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将应用程序从iOS移植到WinRT/8 Metro/8 Immersive/无论当前名称是什么.

I'm working on porting an app from iOS to WinRT/8 Metro/8 Immersive/Whatever the current name is.

在iOS上,我们可以将Application does not run in background设置为YES,以使该应用程序在用户离开应用程序时实际上退出.

On iOS, we have the ability to set Application does not run in background to YES to cause the app to actually quit whenever the user leaves the app.

我想弄清楚如何在WinRT中复制此行为.

I would like to figure out how to replicate this behavior in WinRT.

  1. 是的,我知道这是异常行为.
  2. 是的,我已经深思熟虑了.
  3. 是的,我这样做的理由非常充分.

我假设在userLeavingApp事件期间,我只会调用Application.Current.Exit(),但是我似乎无法找到userLeavingApp事件.我曾考虑过在App.xaml.vb中使用OnSuspending(处理我的挂起),但这对我来说似乎还不够快.

I'm assuming that during the userLeavingApp event, I would just call Application.Current.Exit(), but I can't seem to find the userLeavingApp event. I thought about using OnSuspending (Handles Me.Suspending) in App.xaml.vb, but that doesn't seem to be called quickly enough for me.

.net是否有与viewWillDisappear等效的东西?

Is there a .NET equivalent of viewWillDisappear or something?

有什么想法吗?这是我的应用程序的重要安全特性,由于问题小,我不希望在整个平台上遇到如此困难.

Any ideas? This is an important security characteristic of my app, and I'd hate to have such difficulty in an entire platform due to such a small issue.

谢谢!

推荐答案

我实际上没有看到Application.Current.Exit()在OnSuspending中工作;尽管正如您提到的那样,挂起对于您来说还不够快(这是设计使然).抛出异常对我也不起作用.

I'm not actually seeing Application.Current.Exit() working in OnSuspending; although as you mention the suspending isn't happening fast enough for you (which is by design). Throwing an exception there didn't work for me either.

Window.VisibilityChanged ,如果我在此处发出Exit/exception,则当另一个应用程序接管时,它会关闭该应用程序.就是说,VisibilityChanged也会在其他情况下触发,因此不确定是否可以涵盖所有方案或依靠它们不进行更改. 请参阅此处,以获取更多上下文.

There is Window.VisibilityChanged and if I issue Exit/exception there, it does shutdown the app when another app takes over. That said, VisibilityChanged will fire under other circumstances too so not sure if you could cover all the scenarios or rely on them not changing. See here for a bit more context.

要回显@Filip(其响应刚刚弹出),您极不可能通过认证. Exit()调用等同于异常.

To echo @Filip, whose response just popped in, it's highly unlikely you'll pass certification. An Exit() call is tantamount to an exception.

这篇关于Windows 8 Metro/沉浸式应用程序-强制终止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆