c# – 计时器不包含在Xamarin.Forms的System.Threading中
发布时间:2020-12-16 00:25:46 所属栏目:百科 来源:网络整理
导读:我在Xamarin. Android中使用了System.Threading.Timer. 我如何在Xamarin.Forms中使用相同的类? (我想从Xamarin.Fornd中的Xamarin.Android转移我的项目) public static System.Threading.Timer timer;if (timer == null){ System.Threading.TimerCallback tc
我在Xamarin.
Android中使用了System.Threading.Timer.
我如何在Xamarin.Forms中使用相同的类? public static System.Threading.Timer timer; if (timer == null) { System.Threading.TimerCallback tcb = MyMethod; timer = new System.Threading.Timer(tcb,null,700,System.Threading.Timeout.Infinite); } else { timer.Change(System.Threading.Timeout.Infinite,System.Threading.Timeout.Infinite); timer.Change(700,System.Threading.Timeout.Infinite); } 解决方法
System.Threading.Timer在PCL代码中不可用.
您可以使用Xamarin.Forms.Device.StartTimer方法,如下所述: http://developer.xamarin.com/api/member/Xamarin.Forms.Device.StartTimer/ (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |