简体   繁体   中英

Progress Bar in C#

My problem is I have a method which loading some datas. It took about 10-15 second until the website is loaded. I wanna add a progress bar to the site for the user to show him how long it takes to complete loading the website.

I made a progress bar with pace.js and added it to the .html. The problem is I need something in my controller because the html will start after my method is finished. At the moment I start my website the datas loading and after that my progress bar appears for a second. Could I add my script to a button or is there another solution?

Thanks

The progress bar initializes after the load happened. In fact, the load happens on the server before aything is sent to the browser. I would solve the problem as follows:

  1. I would modify my code to make sure that the slow part of the code does not execute on the server before it responds to the browser and the slow part can be reached via POST requests.

  2. I would have a loaded event in the browser, where I would initialize the progress bar.

  3. After the progress bar is initialized, I would send a separate AJAX code for each subtask of the slow task (yes, I would partition the slow task if possible).

  4. These async AJAX requests would have a callback which would refresh the progress bar's status according to the current situation. The last callback would close the door (finish the progress bar's life-cycle).

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