I have a UWP application that requests Extended Execution in a callback that gets fired after an operation starts like below:
private async void HandleOnSyncStart(ISyncStart msg)
{
// request extended execution
ExtendedExecutionResult result = await
Utils.ExtendedExecutionHelper.RequestExtendedExecutionSessionAsync();
}
, but I get following error
The group or resource is not in the correct state to perform the
requested operation. (Exception from HRESULT: 0x8007139F)
The error is thrown on return call in RequestExtendedExecutionSessionAsync() method shown below. This is the stacktrace:
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()
The extended execution session is requested in RequestExtendedExecutionAsync() method of ExtendedExecutionHelper static class like below:
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
}
This exception is thrown in the constructor of ExtendedExecutionSession
class.
Stacktrace: at Windows.ApplicationModel.ExtendedExecution.ExtendedExecutionSession..ctor()
And this exception can be caused by
Only one ExtendedExecutionSession can be requested at any time; attempting to create another session while one is currently active will cause an exception to be thrown from the ExtendedExecutionSession constructor.
So it looks like ClearExtendedExecutionSession
fails to dispose of a previous running session. If your code is adopted from this page... maybe the code has some subtle bugs, as indicated in some comments on that page.
You could show how you deal with the previous running session.
User contributions licensed under CC BY-SA 3.0