Display progress bar while doing some work in C#?

后端 未结 13 2020
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-27 12:07

I want to display a progress bar while doing some work, but that would hang the UI and the progress bar won\'t update.

I have a WinForm ProgressForm with a Pro

13条回答
  •  天涯浪人
    2020-11-27 13:10

    Use the BackgroundWorker component it is designed for exactly this scenario.

    You can hook into its progress update events and update your progress bar. The BackgroundWorker class ensures the callbacks are marshalled to the UI thread so you don't need to worry about any of that detail either.

提交回复
热议问题