srshawk
srshawk

Reputation: 270

Making call to server when application is in background in Windows Phone 8

I want to make http request to web server periodically say after every 10 secs.

I am using Timer in application which makes http call. Now when application goes to background when user press Windows key.. the timer stops

Can I continue making call to web server?

I referred the VOID chatter box application, but looks like it is for VOIP application only.

Regards,

SRS

Upvotes: 0

Views: 337

Answers (1)

kpaleniu
kpaleniu

Reputation: 316

You have to make a TaskAgent that inherits from ScheduledTaskAgent and override OnInvoke() method. You also need to add the task into WMAppManifest.xml

<Deployment ...>
...
  <App ...>
    ...
    <Tasks>
      <DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
      <ExtendedTask Name="BackgroundTask">
        <BackgroundServiceAgent Name="YourTaskAgent" Type="YourNameSpace.YourTaskAgent" Source="YourTaskAgent" Specifier="ScheduledTaskAgent" />
      </ExtendedTask>
    </Tasks>
  ...
  </App>
...
</Deployment>

Your main application itself cannot continue to perform HTTP requests when it is suspended. For more info see MSDN on background tasks. However, keep in mind that Background Tasks have limitations in what they can do. Hope this helps.

Upvotes: 1

Related Questions