2

I am using Background Task in Windows Phone Mango. I need to send data to server using JSON format. But when DataContractJsonSerializer.WriteObject function is executed, nothing happens thereafter.

Has anyone experienced the same with Background Task in Windows Phone Mango?

dbc
  • 104,963
  • 20
  • 228
  • 340
Ramesh Patel
  • 31
  • 1
  • 4

2 Answers2

2

It is possible that the operation is taking your app over the 6MB memory limit, and the phone is killing it.

You can run with the debugger attached: http://msdn.microsoft.com/en-us/library/microsoft.phone.scheduler.scheduledactionservice.launchfortest(v=vs.92).aspx

This will let you see what is happening. Also consider logging the amount of memory your app is using to see if you are approaching the limit: http://msdn.microsoft.com/en-us/library/microsoft.phone.info.devicestatus(v=vs.92).aspx

Damian
  • 4,723
  • 2
  • 32
  • 53
0

Be careful calling any type of serialization library (or any other library for that matter) as it will very quickly bump your memory usage over the 6MB limit, which will silently kill your agent with no errors.

Also note that on a real device your agent will typically start with 4-4.5 meg used already, significantly higher than on the emulator. That means all your code and the libraries it calls need to use less than 1.5 meg in a worst-case scenario.

Ray Ackley
  • 390
  • 4
  • 9
  • Beware! With the debugger attached DeviceStatus reports way higher memory use then without. With an empty Periodic Task, compiled as debug, a trace to a file on the device shows: peak=2.452KB limit=6.144KB remaining=3.692KB – Peter Meinl Mar 31 '12 at 17:06