在很多场合下, 你需要在主(UI)线程中运行一些比较耗时间的任务,比如以下的任务

l         Image downloads

l         Web service invocations

l         File downloads and uploads (including for peer-to-peer applications)

l         Complex local computations

l         Database transactions

l         Local disk access, given its slow speed relative to memory access

这个时候UI就会陷入一种假死的状态,会给用户带来一种很不好的体验. 如何在这里发挥多线程的优势以改善用户体验? .Net2.0的System.ComponentModel.BackgroundWorker为我们提供了一个很方便的解决方法.

 

BackgroundWorker内部实现是基于delegate的异步调用.

 

backgroundWorkerDemo.zip 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-03
  • 2021-08-16
  • 2021-08-02
  • 2022-12-23
  • 2022-01-19
猜你喜欢
  • 2021-09-27
  • 2021-07-15
  • 2021-10-01
  • 2021-07-24
  • 2021-08-15
  • 2021-07-27
  • 2021-07-15
相关资源
相似解决方案