ScheduledActionService.Find throws ArgumentException

后端 未结 1 766
花落未央
花落未央 2021-01-13 09:59

I have a Windows Phone 7 app deployed in the marketplace that updates its Live Tile via a PeriodicTask Background Agent.

One user is reporting issues with the tile no

相关标签:
1条回答
  • 2021-01-13 10:46

    I managed to reproduce the ArgumentException and StackTrace in the emulator and on a handset attached to my PC.

    The steps were:

    1. Set a break point in an exception handler around the call to ScheduledActionService.Find(TASK_NAME)
    2. Start the app up in the emulator (or handset) with the debugger attached
    3. Use the pin menu item to start the PeriodicTask background agent. Note that in debug mode I call ScheduledActionService.LaunchForTest(TASK_NAME, new TimeSpan(0, 0, 1)); immediately after adding the PeriodicTask.
    4. Navigate to a sub page in my app.
    5. Quickly use the back button to return to the MainPage and then again to quit the applicaiton. The Loaded event on the MainPage calls SetupApplicationBar(), which ultimately calls the ScheduledActionService.Find() method.
    6. As the application is shutting down the exception will occur.

    Exception Type: ArgumentException

    Message: E_INVALIDARG

    StackTrace:

    at Microsoft.Phone.Scheduler.SystemNotificationInterop.CheckHr(Int32 hr)
    at Microsoft.Phone.Scheduler.SystemNotificationInterop.GetNotificationByID(Guid notificationID)
    at Microsoft.Phone.Scheduler.ScheduledActionService.Find(String name)
    at SolarCalculator.Agents.TaskIsActive()
    at SolarCalculator.MainPage.SetupApplicationBar()
    at SolarCalculator.MainPage.MainPage_Loaded(Object sender, RoutedEventArgs e)
    at MS.Internal.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, Delegate handlerDelegate, Object sender, Object args)
    at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr unmanagedObjArgs, Int32 argsTypeIndex, Int32 actualArgsTypeIndex, String eventName)

    Given that the app is shutting down and I'm only trying to figure out if the background agent is running I figure it is safe to catch the exception and return false from my TaskIsActive() method.

    Now that I know the message from the ArgumentException is E_INVALIDARG I found Setting alarm in Windows Phone 7 which describes getting the same error when making calls to ScheduleActionService in the Application_Exit event.

    0 讨论(0)
提交回复
热议问题