[英]Background timer in Xamarin Forms [PCL]
Is this possible Background timer in Xamarin Forms?这是 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即使应用程序关闭,我也想每分钟向服务器发送 lat 日志
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我希望这对你有帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.