简体   繁体   中英

showing status bar first to show progress

Im creating ac# windows form and ive come accross a problem.

When the window opens I am wanting to run a bit of code which can make the front console appear to freeze. The code runs fine but I want to show the status of the program in the status strip at the bottom of the page. I am running the code in the action Form.Shown. However the code does not update the status bar until everything is shown. I can change the label no problem.

How would I go about loading the window and then running the code and updating the status bar (like a background task)?

What areas would I need to look at to get this information?

You could use a BackgroundWorker to do this

Set the WorkerReportsProgress property to true and in the DoWork eventhandler raise the ReportProgress event

in the eventhandler for the ProgressChanged place your logic to update your progresbar

there is a example on msdn

You can use Multithreading to avoid freezing the forms. It means, you separate your form and the code (that you want to run in parallel) in different threads so that the form doesn't wait for the code completes. You can monitor the progress of the code via events.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM