WinRT を使用して Windows Phone 8.1 でイベントを中断すると問題が発生します。イベントが発生しません。どうしてか分かりません。これは私のコードです:
/// <summary>
/// Initializes the singleton application object. This is the first line of authored code
/// executed, and as such is the logical equivalent of main() or WinMain().
/// </summary>
public App()
{
InitializeComponent();
Suspending += OnSuspending;
#if DEBUG
this.displayRequest = new DisplayRequest();
#endif
}
/// <summary>
/// Invoked when application execution is being suspended. Application state is saved
/// without knowing whether the application will be terminated or resumed with the contents
/// of memory still intact.
/// </summary>
/// <param name="sender">
/// The source of the suspend request.
/// </param>
/// <param name="e">
/// Details about the suspend request.
/// </param>
private void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
deferral.Complete();
}
行にブレークポイントを設定し、var deferral = e.SuspendingOperation.GetDeferral();
Visual Studio でデバッグしました。次に、スマートフォンのスタート ボタンを押して、別のアプリを実行し、約 10 秒待ちました。OnSuspending
実行されていません。
何か案は?