[英]Background timer in Xamarin Forms [PCL]
這是 Xamarin Forms 中可能的后台計時器嗎?
我有三個按鈕開始/暫停/停止和計時器文本用於在我的應用程序中顯示計時器。
當用戶單擊開始按鈕時,我想啟動計時器。 一段時間后,用戶將關閉應用程序,但計時器應在后台運行,直到單擊停止按鈕。
即使應用程序關閉,我也想每分鍾向服務器發送 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
}
我希望這對你有幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.