使用WinRT不引發(fā)掛起事件我在WindowsPhone 8.1上使用WinRT掛起事件有問題,它不會觸發(fā)。我也不知道原因。這是我的密碼:/// <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();}我在線路上設(shè)置了一個斷點(diǎn)var deferral = e.SuspendingOperation.GetDeferral();并使用VisualStudio對其進(jìn)行了調(diào)試。然后我按下手機(jī)上的“開始”按鈕,運(yùn)行另一個應(yīng)用程序,等待大約10秒。OnSuspending不是逃跑。有什么想法嗎?
使用WinRT不引發(fā)掛起事件
一只甜甜圈
2019-07-11 10:40:26