locked
ScheduledTask doesn't work anymore?

    Question

  • Hi All,

    I have developed a Windows Phone 8.0 App in C# with a ScheduledTask what was working fine until I migrated the solution/project to Silverlight W8.1.

    Now the ScheduledTask only work when I'm debugging using the emulator or when i'm debugging on the device.

    But when I deploy the App to the device (same device where the ScheduledTask did work while debugging the App), you can wait until you're old and grey ;-) but the ScheduledTask doesn't do anything anymore.

    I even changed the ScheduledTask code so it display a simple toast massage whenever it's trigged, have checked this http://msdn.microsoft.com/library/windows/apps/hh202941(v=vs.105).aspx over and over again to be sure I didn't miss anything, but still it isn't working.

    Is it because my device is running on the latest Windows phone developer preview OS version? Is there a bug?

    I have no idea anymore, hope someone does.

    Kind regards,

    Arthur

    Friday, August 22, 2014 6:50 PM

Answers

  • Hi All,

    My ScheduledTask is working again, what did I do:

    Change my ScheduledTask code into a code so that it only showed a simple hard coded toast message, even that didn't work on my Windows Phones devices (Lumia 920 and 630).

    It only worked on the emulator of Visual Studio, and the difrences between the emulator and my phones are that my phones are working with the latest update of the Developer Preview OS and the emulator on the standard 8.1 OS version.

    So I took my Lumia 630 and reset it to the factory settings, after the reset I didn't choose to restore a backup, deployed the App to my phone with the simple toast message in the ScheduledTask, and it worked.

    Then I putted the original code back in the ScheduledTask, and deployed my App again to my phone, and now the ScheduledTask is working fine and smooth again :-)

    This means that there is something wrong with the latest update of the Developer Preview OS, and I guess it also explain that some of the Apps what I have installed from the App store are also not showing their notification anymore.

    Best regards,

    Arthur

    • Marked as answer by ArtoriusCPP Sunday, August 24, 2014 11:06 AM
    Sunday, August 24, 2014 11:04 AM

All replies

  • Hi ArtoriusCPP,

    I think this will be case  with your application. Windows Phone background agents can only handle Maximum peek of 11MB. If once memory peek is go above than 11MB OS automatically block the background agent.

    Try to make your notification with dispatcher. One after one
    Example :

    ActionQueue(true,
    ()=> NotificationFuntion(),
    ()=>NotificationFuntion());

    Hope that helps
    Please don't forget to up vote answers you like or which help you and mark one(s) which answer your question.

    ---------------------------------------

    M Prabath Maduranga Peiris
    Microsoft Student Partner
    Blogs : prabathsl.blogspot.com

     

    Friday, August 22, 2014 7:04 PM
  • Hi M Prabath Maduranga Peiris,

    Thanks for the fast reply, but even with a simple toast massage in the ScheduledTask as you can see bellow, I have the same problem, and don't think that this piece of code is above the 11MB, or am I wrong?

    protected override void OnInvoke(ScheduledTask task)
            {
                //TODO: Add code to perform your task in background
                string toastMessage = "";
    
                // If your application uses both PeriodicTask and ResourceIntensiveTask
                // you can branch your application code here. Otherwise, you don't need to.
                if (task is PeriodicTask)
                {
                    // Execute periodic task actions here.
                    toastMessage = "Periodic task running.";
                }
                else
                {
                    // Execute resource-intensive task actions here.
                    toastMessage = "Resource-intensive task running.";
                }
    
                // Launch a toast to show that the agent is running.
                // The toast will not be shown if the foreground application is running.
                ShellToast toast = new ShellToast();
                toast.Title = "Background Agent Sample";
                toast.Content = toastMessage;
                toast.Show();
    
                // Call NotifyComplete to let the system know the agent is done working.
                NotifyComplete();
    }

    Friday, August 22, 2014 7:19 PM
  • Hi All,

    My ScheduledTask is working again, what did I do:

    Change my ScheduledTask code into a code so that it only showed a simple hard coded toast message, even that didn't work on my Windows Phones devices (Lumia 920 and 630).

    It only worked on the emulator of Visual Studio, and the difrences between the emulator and my phones are that my phones are working with the latest update of the Developer Preview OS and the emulator on the standard 8.1 OS version.

    So I took my Lumia 630 and reset it to the factory settings, after the reset I didn't choose to restore a backup, deployed the App to my phone with the simple toast message in the ScheduledTask, and it worked.

    Then I putted the original code back in the ScheduledTask, and deployed my App again to my phone, and now the ScheduledTask is working fine and smooth again :-)

    This means that there is something wrong with the latest update of the Developer Preview OS, and I guess it also explain that some of the Apps what I have installed from the App store are also not showing their notification anymore.

    Best regards,

    Arthur

    • Marked as answer by ArtoriusCPP Sunday, August 24, 2014 11:06 AM
    Sunday, August 24, 2014 11:04 AM