public DispatcherTimerSample()
{
InitializeComponent();
DispatcherTimer timer = new DispatcherTimer();
timer.Tick += new EventHandler(DispatcherTimer_Tick);
timer.Tick += timer_Tick;
timer.Start();
}
///运行一次
private void DispatcherTimer_Tick(object sender, EventArgs e)
{
timer.IsEnabled = false;
//Task t1 = new Task(() => {
// MainFangfa();
//});
启动Task
//t1.Start();
Task.Run(async () =>
{
await Dispatcher.InvokeAsync(() =>
{
MainFangfa();
});
});
}
WPF下的DispatcherTimer计时器
最新推荐文章于 2024-03-06 19:34:42 发布