Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Timer Speed is increasing on picker selection change

$
0
0

I am creating a timer which is working on a picker selection changed.Timer is working good until the times end to the "00:00:00".If i change the selection changed in the mid of time then the speed of timer is increased and if i again change selected index than timer run much fast. My problem is that timer should run on 1 sec dealy every time.
I am sharing my code below. Thanks in advance for help.

           private async void GName_SelectedIndexChanged(object sender, EventArgs e)
            {

            lblEndTime.Text = "00:00:10";

            StartTimmer();

            }

         public void StartTimmer()
          {
        Device.StartTimer(TimeSpan.FromSeconds(1), () =>
            {

            Device.BeginInvokeOnMainThread(() =>
          {
              TimeSpan timeSpan = TimeSpan.Parse(lblEndTime.Text);

              timeSpan -= TimeSpan.FromSeconds(1);

              if (lblEndTime.Text == "00:00:00")
              {
                  returnValue = false;

              }
              else
              {
                  lblEndTime.Text = Convert.ToString(timeSpan);

              }

          });

            return returnValue;
        });
     }

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>