简体   繁体   中英

Background timer in Xamarin Forms [PCL]

Is this possible Background timer in Xamarin Forms?

I have three buttons Start/Pause/Stop and Timer Text for showing the timer in my app.

When the user clicks on start button i want to start the timer. After some time user will close the app but timer should run in the background until stop button clicks.

and I want to send lat log to the server every minute even if the app is closed

private void OnStartbuttonClicked(object sender, EventArgs e)
    {
        // Save the Time, when the Timer starts
    }

    private void OnStopbuttonClicked(object sender, EventArgs e)
    {
        DateTime starttime = DateTime.Parse("String with the Time, when the Timer starts");
        DateTime endTime = DateTime.Now;


        TimeSpan difference = endTime - starttime;

        // difference ist the time of the timer
    }

I hope this helps you

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM