在WPF MVVM应用程序中的特定时间调用函数 [英] Calling a function at a specific time in WPF MVVM application
本文介绍了在WPF MVVM应用程序中的特定时间调用函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在特定时间在C#-WPF MVVM应用程序上调用特定函数.我在应用程序中使用System.Timers,但后来我意识到使用它无法实现我的目标.
有人可以建议我为此提供一个好的解决方案吗??
在此先感谢... !!!
I want to call a specific function on my C#-WPF MVVM application at a specific time.I''m using System.Timers in My application.But later I realized that its impossible to achieve my goal using that.
Is anybody can suggest me a good solution for this.?
Thanks in advance...!!!
推荐答案
为什么您意识到System.Timers
是不可能的
但是对我来说效果很好!
Why did you realize thatSystem.Timers
was impossible
But it works well for me!
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
Dispatcher.Invoke((Action)delegate()
{
if(Your Conditions)
YourMethod();
});
}
这篇关于在WPF MVVM应用程序中的特定时间调用函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文