天天看點

重新想象 Windows 8 Store Apps (42) - 多線程之線程池: 延遲執行, 周期執行, 線上程池中找一個線程去執行指定的方法

<a href="http://files.cnblogs.com/webabcd/Windows8.rar">[源碼下載下傳]</a>

重新想象 Windows 8 Store Apps (42) - 多線程之線程池: 延遲執行, 周期執行, 線上程池中找一個線程去執行指定的方法

介紹

重新想象 Windows 8 Store Apps 之 線程池

通過 ThreadPoolTimer 實作延遲執行

通過 ThreadPoolTimer 實作周期執行

通過 ThreadPool 實作“線上程池中找一個線程去執行指定的方法”

示例

1、通過 ThreadPoolTimer 實作延遲執行(ThreadPoolTimer 在 Windows.System.Threading 命名空間下)

Thread/ThreadPool/DelayTimer.xaml

Thread/ThreadPool/DelayTimer.xaml.cs

2、通過 ThreadPoolTimer 實作周期執行(ThreadPoolTimer 在 Windows.System.Threading 命名空間下)

Thread/ThreadPool/PeriodicTimer.xaml

Thread/ThreadPool/PeriodicTimer.xaml.cs

3、通過 ThreadPool 實作“線上程池中找一個線程去執行指定的方法”(ThreadPool 在 Windows.System.Threading 命名空間下)

Thread/ThreadPool/WorkItem.xaml

Thread/ThreadPool/WorkItem.xaml.cs

OK