Click here to Skip to main content
15,884,176 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have several list collections(i.e list1,list2 list3...etc)
and i have one xml file(i.e data.xml).I am storing the xml data to my suitable lists(i.e edge data in list1, subpart data in list2 like this...)
Now after storing the xml data in list collections i want to save this data from list to data base.
Till my coding is doing fine working properly and date are geting save into database.

But this entire process is time taking and user does not know when this process will completeed.Basicaly the xml file is not fixed.i will get sevaral xml file with more or less data(data structure of xml file is same).

I want to implement the progress bar here to inform how many hours or minutes or seconds left to to finise the entire process from storing xml data into list to saving data in database

can anyone give me idea about it...


with regards
tarak
Posted

First you have to get the total size of the data (files). Then after the first file has been saved you know how long it took (in seconds). Now you can calculate a rough estimate of how long it would take to save the rest of the data.

An example:
startTime = Now

DoWork()

duration = Now - startTime   // In seconds
sizeDone = sizeDone + currentFileSize
eta = (totalSize - sizeDone) / currentFileSize * duration


But like Pete said in his answer, you cannot predict network errors or anything like that. However, if the network slows down during the saving process, the estimation will be adjusted accordingly because it's constantly updated.
 
Share this answer
 
As far as I know it is not possible to show the exact time remining. the best solution is divide your total processing to sevaral steps and give each one some persentage of the total time as an example
You have to do a task which has 4 steps step 1 take approx 20% step 2 take 30% step 3 take 25 % and step 4 take 25%.you write a function wich will increment the progress bar to a given value in specified intervals
say AutoUpdateProgress(interval,targetvalue)

Example:
AutoUpdateProgress(100,20);
{
Do step 1
}
SetProgress(20);// on completion of the step on you set the progressbar value =20
AutoUpdateProgress(100,30);
{
Do step 2
}
...
 
Share this answer
 
v2
TARAK NATH ROY wrote:
I want to implement the progress bar here to inform how many hours or minutes or seconds left to to finise the entire process from storing xml data into list to saving data in database


You can't really do this. When you think about it, progress is dependent on many factors outside your control, such as network latency, server load, type of operation to be performed, other processes running on your machine, and so on. So all you can do is give (at best), a rough approximation of how long it will take.

Most algorithms work by knowing how many operations need to be performed, and then start by calculating how long one operation takes - then extrapolating the total time from this. After a certain number of operations, this figure is refined because there is greater statistical sampling at this stage. This is done over and over, until the operation is finally completed.

 
Share this answer
 


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900