使用WinRT不引發掛起事件我在WindowsPhone 8.1上使用WinRT掛起事件有問題,它不會觸發。我也不知道原因。這是我的密碼:/// <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();并使用VisualStudio對其進行了調試。然后我按下手機上的“開始”按鈕,運行另一個應用程序,等待大約10秒。OnSuspending不是逃跑。有什么想法嗎?
3 回答

月關寶盒
TA貢獻1772條經驗 獲得超5個贊
- 3 回答
- 0 關注
- 651 瀏覽
添加回答
舉報
0/150
提交
取消