Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

CountDownTimer Run even if app is closed?

lukasrein97lukasrein97 USMember ✭✭✭

Hi guys i have a button and when i click this button i want that the timer countdown 30min and update the button text with the seconds left from that 30 min.

All work fine but when i close my app and go back the countdowntimer is resettet.
I want that even if the app is closed the countdowntimer doesnt stop. How can i do that?
This is my working code so far:

            ad1 = FindViewById<Button>(Bash_It.Resource.Id.ad1);
            ad1.Click += delegate {
                _timer = new System.Timers.Timer();
                _timer.Interval = 1000;
                _timer.Elapsed += OnTimedEvent;
                _countSeconds = 1800;
                _timer.Enabled = true;
        private void OnTimedEvent(object sender, System.Timers.ElapsedEventArgs e)
            RunOnUiThread(() => {
            ad1.Text = _countSeconds.ToString() + " Seconds left from 30 Minutes!";
                if (_countSeconds == 0)
                    button1text = "Finished!";


Sign In or Register to comment.