Add Hang Prevention guidance from Sébastien Lachance
https://www.dotnetapp.com/hang-on/
This commit is contained in:
Родитель
ee38f3ac39
Коммит
cfbb29d86a
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче