How to use Progress bar during loading an xml File

前端 未结 4 1930
伪装坚强ぢ
伪装坚强ぢ 2021-01-06 05:32

I want to show progress bar during loading a Remote xml file. I am using Windows Application Form in Visual C# 2008 Express Edition.

private void button1_Cl         


        
4条回答
  •  渐次进展
    2021-01-06 06:11

    First it might be going too fast for you to see - try putting a Sleep in there if you're testing that, but further, the reason it's not updating is that you're processing and that happens on the same thread that the main UI is using.

    You can have the program process all events by calling Application.DoEvents() but by doing so, you also reprocess anything the user might have clicked on (including this button) - so if you want to DoEvents and make sure you don't end up processing additional work, disable the form when the method starts.

    All that said, a better model is to thread your work and update the progress bar on a timer or a callback.

提交回复
热议问题