■ SuspendingDeferral 클래스를 사용해 비동기 처리를 대기하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
using Windows.ApplicationModel; using Windows.Storage; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; ... private TextBox textBox; ... Application.Current.Suspending += Application_Suspending; ... private async void Application_Suspending(object sender, SuspendingEventArgs e) { SuspendingDeferral suspendingDeferral = e.SuspendingOperation.GetDeferral(); await PathIO.WriteTextAsync("ms-appdata:///local/sample.txt", this.textBox.Text); suspendingDeferral.Complete(); } |