public static void timerElapsed(object o, EventArgs e) { //DisplayAlert ("Alert", DateTime.Now.ToString() , "OK"); Xamarin.Forms.Device.BeginInvokeOnMainThread(() => { timer.setInterval(timer.getInterval() + 1000); label.Text = "Hello, " + DateTime.Now; }); }
public void timerElapsed(object o, EventArgs e) { Device.BeginInvokeOnMainThread(() => // this function is called each second { if (timerFlag) { timer.setInterval(timer.getInterval()); timerTime -= 1000; //-1s per second if (timerTime < 0) // what to do when timer reaches 00:00 { if (phase % 2 == 0) //each even phase is a working phase { SetTimer(3); rounds -= 1; } else //odd phase = rest phase { if (phase == 7) { SetTimer(5); } // last phase is a relaxation phase else { SetTimer(4); // otherwise, 5 min rest } } if (phase > 7) { phase = 0; } else { phase += 1; } if (rounds == 0) { onReset(); } } else { onTick(timerTime); } } }); }
public void StartWithInactivityInterval() { timer.stopTimer(); timer.setInterval(InactivityIntervalInMs); timer.startTimer(); }