Timer doesn't contain in System.Threading at Xamarin.Forms

前端 未结 3 676
北海茫月
北海茫月 2021-01-14 11:29

I used System.Threading.Timer in Xamarin.Android.

How I can use the same class in Xamarin.Forms? (I want to transfer my projec

3条回答
  •  余生分开走
    2021-01-14 12:11

    Hi I found solution for the timer in Xamarin.forms

    1. Device.StartTimer(TimeSpan.FromMilliseconds(1000), OnTimerTick); // TimeSpan.FromMilliseconds(1000) specify the time in milisecond //OnTimerTick it is function that will be executed return boolean

      1. private bool OnTimerTick() { // code to be executed lblTime.Text = newHighScore .ToString(); newHighScore++; return true; }

    I hope you get my point easily thanks.

提交回复
热议问题