Timer lags in Xamarin android

We were developing a cross-platform app for iOS and Android which uses a timer (so we are using the Device.StartTimer Thread).
While testing our app against the google stopwatch, the iOS version of the app lines up perfectly (in a timespan of 150000 milliseconds), but the Android app falls 10000 milliseconds behind by the end of the 150000 milliseconds.
I have tried disabling the Mono Runtime, but the app still shows this behavior.
I would appreciate any help on this!


  • YorkGoYorkGo CNMember, Xamarin Team Xamurai

    Could you please post more detailed codes? or maybe share a basic demo that can reproduce the problem through online repo. Please elaborate a bit more. I don't get what you mean.

  • shreystechshreystech Member ✭✭
    edited January 28

    Here is a snippet of code that lags. I will try to publish a video of what I mean about the lag. So basically, the timer stops automatically at 2 minutes and 30 seconds. However, this timer is behind the real clock (it takes longer than 2 minutes and 30 seconds). This same code does not lag on the iOS Version of the application:

        Device.StartTimer(TimeSpan.FromMilliseconds(ConstantVars.TIMER_INTERVAL_ANDROID), () =>
                                if (timerValue >= ConstantVars.MATCH_SPAN_MS || !isTimerRunning)
                                    startTimer.Text = ConstantVars.TIMER_START;
                                    return false;
                                Timer_Elapsed(); return true;

    This snippet calls the Timer_Elapsed method to increment the time by the amount ConstantVars.TIMER_INTERVAL_ANDROID and checks if the timer has met the ConstantVars.MATCH_SPAN_MS value, which is 2 minutes and 30 seconds (150000 milliseconds)

    Thank you for your help!

Sign In or Register to comment.