locked
Running a timer

    Question

  • This may not be a nice question to ask. I need to run an operation every 1 or 2 minutes in my C++ metro app. I plan to run this on a timer event using DispatchTimer, though I know that the Interval value of the timer is not advisable to be set beyond a certain limit. ( it shows warning sometimes if set a beyond the limit). Is it a nice approach to have a timer fire every 1 or 2 minutes in a Metro app ?

    I could have gone for background task for my purpose, but background tasks fire only at 15 minutes interval and that's too long a period for this purpose. Also, the app needs to be placed on lock screen for background tasks. Any other approach if timer approach is not good for my purpose?

    Tuesday, September 11, 2012 6:50 PM

Answers

  • Hi its_me_here,

    How best to do this really depends on the app and what you need the timer for. Using a DispatcherTimer may be quite appropriate, and if one will do the job then it is likely a good solution. That said, we cannot give useful advice about if a DispatcherTimer is appropriate for your purpose without knowing what your purpose is.

    The big problem with running a timer is that it can prevent the system from sleeping, and this can be worse if done from a background task since it will run even when the app isn't being used. This is part of why timer tasks are limited.

    --Rob

    • Marked as answer by Jesse Jiang Monday, October 01, 2012 7:31 AM
    Wednesday, September 12, 2012 6:34 AM
    Owner