C# DispatcherTimer:传入自定义参数小技巧

来源:互联网 发布:2011选秀动态体测数据 编辑:程序博客网 时间:2024/05/21 06:43

问题:如何在DispatcherTimer的事件响应函数Tick()中,操作用户自定义对象?

解决:我们可以利用DispatcherTimer的Tag属性,给它赋值为用户自定义的对象,就可以在Tick()函数中访问用户自定义对象了。

附:MSDN:http://msdn.microsoft.com/en-us/library/system.windows.threading.dispatchertimer(v=vs.110).aspx

Dispatcher class is——

Provides services for managing the queue of work items for a thread.(为线程工作项队列管理提供方法)

DispatcherTimer class is——

A timer that is integrated into the Dispatcher queue which is processed at a specified interval of time and at a specified priority.(一个集成在Dispatcher类中的定时器,在指定时间间隔以指定的优先级触发)



0 0