您可以使用该Device.StartTimer(TimeSpan minutes)方法启动在给定时间跨度后将重复的后台任务.这是一个代码示例:
var minutes = TimeSpan.FromMinutes (3);
Device.StartTimer (minutes, () => {
// call your method to check for notifications here
// Returning true means you want to repeat this timer
return true;
});
Run Code Online (Sandbox Code Playgroud)
这包含在Xamarin Forms中,因此您不需要任何特定于平台的逻辑.
| 归档时间: |
|
| 查看次数: |
12248 次 |
| 最近记录: |