2017-10-24 10 views
1

は私が運転した後に解雇ますコールバックで拡張実行を要求UWPアプリケーションを持って要求して以下のように起動します:UWP ExtendedExecutionエラー拡張実行

private async void HandleOnSyncStart(ISyncStart msg) 
{ 
    // request extended execution 
    ExtendedExecutionResult result = await 
     Utils.ExtendedExecutionHelper.RequestExtendedExecutionSessionAsync(); 
} 

が、私はエラーに

The group or resource is not in the correct state to perform the 
requested operation. (Exception from HRESULT: 0x8007139F) 
を以下の取得します

RequestExtendedExecutionSessionAsync()メソッドの返信時にエラーがスローされます。これは、スタックトレースです:

at Windows.ApplicationModel.ExtendedExecution.ExtendedExecutionSession..ctor() 
    at MyProject.UWP.Utils.ExtendedExecutionHelper.<RequestExtendedExecutionSessionAsync>d__0.MoveNext() 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) 
    at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() 
    at MyProject.UWP.MainPage.<HandleOnSyncStart>d__65.MoveNext() 

拡張実行セッションが(RequestExtendedExecutionAsyncに要求されている)以下のようなExtendedExecutionHelper静的クラスのメソッド:

public static async Task<ExtendedExecutionResult> RequestExtendedExecutionSessionAsync() 
    { 
     ClearExtendedExecutionSession(); //first clear if any session granted 

     var newSession = new ExtendedExecutionSession(); 
     newSession.Reason = ExtendedExecutionReason.Unspecified; 
     newSession.Description = "Extended Execution Request"; 
     newSession.Revoked += OnExtendedExecutionSessionRevoked; 

     ExtendedExecutionResult result = await newSession.RequestExtensionAsync(); 
     switch (result) 
     { 
      case ExtendedExecutionResult.Allowed: 
       Debug.WriteLine(string.Format("ExtendedExecutionHelper: ExtendedExecution allowed.")); 
       session = newSession; 
       break; 
      case ExtendedExecutionResult.Denied: 
       Debug.WriteLine(string.Format("ExtendedExecutionHelper: ExtendedExecution denied.")); 
       newSession.Dispose(); 
       break; 
     } 

     return result; //ERROR 
    } 

答えて

2

この例外は​​クラスのコンストラクタでスローされます。

スタックトレース:Windows.ApplicationModel.ExtendedExecution.ExtendedExecutionSession..ctorで ()

そして、この例外が一つだけExtendedExecutionSessionはいつでも要求することができる

が原因で発生することができ;現在アクティブな状態で別のセッションを作成しようとすると、ExtendedExecutionSessionコンストラクターから例外がスローされます。

したがって、ClearExtendedExecutionSessionは以前の実行セッションを破棄していないようです。あなたのコードがthis pageから採用されていれば、おそらくそのページのコメントに示されているように、コードには微妙なバグがあります。

前回の実行セッションの処理方法を示すことができます。

+0

私はそのページのエラーを認識しており、修正しました。しかし、セッションをインスタンス化するときにエラーが発生しないように、エラーのコード行を見てください。私はEES ctorコールからエラーを取得していないので、複数のEESで何かをしなければならないとは思わない。ありがとう – pixel

+0

実際、あなたは正しいです、私はEES c-torを次々と2回呼び出すことを試みました、そして、それは私が得たものです。ありがとう、 – pixel