Difference between BackgroundWorker and Thread?

前端 未结 7 1646
南旧
南旧 2020-12-07 00:58

What is the difference between BackgroundWorker and Thread? In my application I am using a messaging system that communicates with the database reg

7条回答
  •  长情又很酷
    2020-12-07 01:29

    While the BackgroundWorker class isn't derived from the Thread class it enables you to manage the work a thread does much more easily than if you created and invoked the thread yourself.

    It raises three key events:

    • DoWork - raised when the thread starts.
    • ProgressChanged - raised to report progress to the main UI thread.
    • RunWorkerCompleted - raised when the thread completes.

    With these you can monitor the work the thread is doing after you call RunWorkerAsync() to start it.

提交回复
热议问题