Add Hang Prevention guidance from Sébastien Lachance

https://www.dotnetapp.com/hang-on/
This commit is contained in:
michael-hawker 2021-03-24 16:15:09 -07:00
Родитель ee38f3ac39
Коммит cfbb29d86a
1 изменённых файлов: 14 добавлений и 2 удалений

Просмотреть файл

@ -3,6 +3,7 @@
// See the LICENSE file in the project root for more information.
using System;
using System.Threading.Tasks;
using Microsoft.Toolkit.Uwp.Helpers;
using Microsoft.Toolkit.Uwp.SampleApp.Common;
using Microsoft.Toolkit.Uwp.SampleApp.SamplePages;
@ -163,7 +164,7 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
/// </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)
private async void OnSuspending(object sender, SuspendingEventArgs e)
{
var deferral = e.SuspendingOperation.GetDeferral();
@ -179,7 +180,18 @@ namespace Microsoft.Toolkit.Uwp.SampleApp
// ignore
}
deferral.Complete();
try
{
await Task.Delay(2000);
}
catch
{
// ignore
}
finally
{
deferral.Complete();
}
}
}
}