简体   繁体   中英

How to get Progress Update if software is undergoing a long process in c# windows application

How to get Progress Update if software is undergoing a long process in c# windows application?

I am working on a project which is retrieving data from database but sometimes it takes a little more time depending upon CPU usage and at loading time i want to show message that data is loading . How to achieve this?

any help would be appreciated

  1. Show message before loading data.
  2. Load Data.
  3. Hide/Remove the message.

Edit:

To show after specific interval.

  1. Start a timer for an interval which you think counts as long.
  2. Start loading data.
  3. On timer tick, stop the timer display the message.
  4. Hide/Remove the message after data loading is complete.

if you want it to become more meaning full, then as the timer tick check how much data has been loaded, lets say only 50% then show the message. If lets say 90% then don't show the message.

You need to show progress through some GUI. Please have a look at these links:

.Net Framework has a class BackgroundWorker that deals with situations like your case

you can read about it here: How to use background worker

  1. display ShowModel form containing Loading image
  2. run the worker to load the data
  3. once the Background worker completed (you can know by handle the event RunWorkerCompleted), close this form in this event

hope that this will help you

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