Tôi đang gặp sự cố khi tạm dừng sự kiện trên Windows Phone 8.1 bằng WinRT, nó không kích hoạt. Tôi không biết tại sao. Đây là mã của tôi:Sự kiện tạm dừng không tăng khi sử dụng 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();
}
Tôi đặt điểm ngắt trên dòng var deferral = e.SuspendingOperation.GetDeferral();
và gỡ lỗi nó bằng Visual Studio. Sau đó, tôi nhấn nút khởi động trên điện thoại của mình và chạy một ứng dụng khác và đợi khoảng 10 giây. OnSuspending
không hoạt động.
Bất kỳ ý tưởng nào?
Bạn có thể vui lòng cung cấp bất kỳ liên kết chứng minh nào không? – CAMOBAP
@CAMOBAP Một liên kết chứng minh cho những gì? – Romasz
Liên kết bằng chứng cho tuyên bố "Sự kiện tạm ngưng sẽ không kích hoạt khi bạn đang gỡ lỗi" (nếu có) – CAMOBAP