c#怎么回收dispatchertimer

如题所述

DispatcherTimer比较特殊,这个类没有实现IDisposable接口。换句话讲DispatcherTimer类不提供Dispose()方法,

要回收DispathTimer对象,可以用以下方法:

DispatherTime m_timer = new DispatherTimer();
....
// 确保定时器不活动
m_timer.Stop();
// 将m_timer设置为null
m_timer = null;
// 启动强制垃圾回收
GC.Collection();

温馨提示:答案为网友推荐,仅供参考
相似回答