Right way of using Backgroundworker

纵然是瞬间 提交于 2019-12-08 19:24:26

I feel like you are doing this a bit backwards. Backgroundworker should do the work while your main process is displaying the current form and possibly updating it. When the backgroundworker has finished loading your data it should process it in the main thread in the backgroundworker event 'RunWorkerCompleted'.

This will also simplify your code since you do not need to your invokes before closing or hiding the form.

I hope this answered your question. //Flipbed

Here is some great articles that may help you get what you want :

C# BackgroundWorker Tutorial

BackgroundWorker Class Sample for Beginners

BackgroundWorker and ProgressBar demo

Backgroundworker example

Hope this Helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!