Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compact Framework - System.Threading.Timer stops when the user turns off the screen

I have an application that needs to "poll" a webservice to see if the user has any new messages waiting. I have no control over the webservice so I cannot switch to a "push" mechanism, I'm stuck making a request every X number of seconds to see what's available.

I am using a System.Threading.Timer to make the request every so often, but am encountering a few problems. The biggest is that it stops running when the phone is sent into "standby" mode (screen off, but still able to get calls and email/txt notifications).

I'd really like it to behave like other background applications. What can I do to make it work without being too big of a drain on the battery?

like image 303
Jake Stevenson Avatar asked Nov 12 '08 15:11

Jake Stevenson


2 Answers

Hate to answer my own question, but I was pointed to this, which was able to perform even when the device is asleep. Looks like it's working perfectly.

like image 190
Jake Stevenson Avatar answered Sep 28 '22 11:09

Jake Stevenson


There's nothing you can do, AFAIK. Standby mode is meant to suspend the processor to save power, and there's no way your code can execute if the processor isn't running. There are things your application can do to prevent the device from going into standby mode, but this really isn't advisable at all.

like image 43
MusiGenesis Avatar answered Sep 28 '22 11:09

MusiGenesis