2016-04-29 9 views
0

私のWindowsストアアプリケーションでは、待ち時間があり、完了まで数分かかる場合があります(他のスレッドのパフォーマンスについては相談します)。一方、ユーザーがアプリケーションからフォーカスを外すと、クラッシュします。私は、アプリケーション内のプリズムを使用していますWindows UWP、非同期呼び出し中に中断中にアプリケーションがクラッシュする

App was terminated because it took too long to suspend.

:私はイベントログをチェックすると、私は次のエラーを得ました。ナビゲーションパラメータを保存するため、

protected void OnApplicationSuspending(object sender, SuspendingEventArgs e) 
    { 
     var defferal = e.SuspendingOperation.GetDeferral(); 
     if (sessionStateService.SessionState.ContainsKey("plotId")) 
     { 
      sessionStateService.SessionState.Remove("plotId"); 
     } 

     sessionStateService.SessionState.Add("plotId", Plot.Id); 

     if (sessionStateService.SessionState.ContainsKey("Page")) 
     { 
      sessionStateService.SessionState.Remove("Page"); 
     } 

     sessionStateService.SessionState.Add("Page", "OperationRecording"); 

     defferal.Complete(); 
    } 

私も機能をOnNavigatingFrom上書きしている(と、それは他に何もしません):私は(いつもと呼ばれている)次のコードで、Application.Current.Suspendingを取り扱っています。

public override void OnNavigatingFrom(NavigatingFromEventArgs e, Dictionary<string, object> viewModelState, bool suspending) 
    { 
     if (viewModelState.ContainsKey("plotId")) 
     { 
      viewModelState.Remove("plotId"); 
     } 

     viewModelState.Add("plotId", Plot.Id); 

     base.OnNavigatingFrom(e, viewModelState, suspending); 
    } 

この問題を解決する方法はわかりません。

答えて

3

アプリを停止する場合は、5秒後に完了する必要があります。
読むApplication.Suspending

Saving data prior to suspension is useful because the Suspending event handler has only 5 seconds to complete its operation.

ので、より良いデータによるアプリケーションの作業を大量に保存してください。
また、あなたはまた、拡張実行の助けを借り

で中断時間を大きくすることができますUWPで Guidelines for app suspend and resume

を読むことができます

関連する問題