博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Different timers in .net
阅读量:4556 次
发布时间:2019-06-08

本文共 1042 字,大约阅读时间需要 3 分钟。

  • Multi-threads timers: System.Threading.Timer and System.Timers.Timer (.net framework):

App will handle timer event on a thread pool thread. Timers.Timer is a wrapper for Threading.Timer. They are used for doing time-consuming tasks. 

If a  is used in a WPF application, it is worth noting that the  runs on a different thread then the user interface (UI) thread.

In order to access objects on the user interface (UI) thread, it is necessary to post the operation onto the  of the user interface (UI) thread using  or 

.

Reasons for using a DispatcherTimer opposed to a  are that theDispatcherTimer runs on the same thread as the  and a 

 can be set on the DispatcherTimer.

  • Single-thread timers: System.Windows.Forms.Timer(Windows Forms Timer)and System.Windows.Threading.DispatcherTimer(WPF timer)
Based on Windows message loop, app will handle timer event synchronously, so they may block UI.
They are called in the same thread as the application. They are

 used for small tasks such as updating UI.

转载于:https://www.cnblogs.com/chuwachen/p/3911002.html

你可能感兴趣的文章
error: .repo/manifests/: contains uncommitted changes
查看>>
逆元(inv)
查看>>
CentOS Docker 安装
查看>>
debian(kali Linux) 安装net Core
查看>>
centos 7防火墙设置
查看>>
自定义进度条(圆形、横向进度条)
查看>>
spark-streaming-kafka采坑
查看>>
9.Mongodb与python交互
查看>>
18-[JavaScript]-函数,Object对象,定时器,正则表达式
查看>>
读取短信回执
查看>>
EF 数据初始化
查看>>
PreparedStatement与Statement
查看>>
WebService -- Java 实现之 CXF ( 使用CXF工具生成client 程序)
查看>>
Factorial
查看>>
Android开发中,9-patch 图片设置背景带来的问题
查看>>
剑指Offer-反转链表
查看>>
[LeetCode]Two Sum
查看>>
java 常用集合list与Set、Map区别及适用场景总结
查看>>
HTML与javascript语法
查看>>
Android学习--网络通信之网络图片查看器
查看>>