如何解决在C#中停止System.Timers
我正在使用System.Timers
,而计时器正在完美地工作,例如在Second 4,8,12,16
上拍照。
但是,我希望它在Second 17
上导航,但不会。
public partial class CustomCameraPage : ContentPage
{
private static Timer timer_click;
int Seconds = 0;
public CustomCameraPage()
{
timer_click = new Timer();
timer_click.Interval = 1000;
timer_click.Elapsed += OnTimedEvent;
timer_click.Enabled = true;
timer_click.AutoReset = true;
timer_click.Start();
InitializeComponent();
}
public void OnTimedEvent(object source,ElapsedEventArgs e)
{
Seconds++;
if (Seconds == 4 || Seconds == 8 || Seconds == 12 || Seconds == 16) MessagingCenter.Send<object>(this,"A");
if (Seconds == 17) Navigation.PushModalAsync(new FormPage());
}
}
解决方法
上执行导航
return Transaction.aggregate([ { $match : { userId : userId,type:"Income",isActive:true} },{
$group: {
_id: "$type",amount: {
$sum: "$amount"
}
}
}
]).then((totalIncome,err)=> {
// return (err) ? false : totalIncome
console.log(totalIncome)
if (err) {
return false
} else {
User.findByIdAndUpdate(userId,{"$set" : {"totalIncome": totalIncome[0].amount }},{ "new": true })
.then((transaction,err ) => {
return (err) ? false : true
})
}
})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。