Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NETCF .NET
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 4-Jun-09 20:08pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.

  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
}
...
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

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.
  Permalink  
  Print Answers RSS
0 OriginalGriff 468
1 Sergey Alexandrovich Kryukov 305
2 PhilLenoir 115
3 RajeeshMenoth 110
4 Peter Leow 100
0 Sergey Alexandrovich Kryukov 6,557
1 OriginalGriff 5,966
2 CPallini 2,473
3 Richard MacCutchan 1,687
4 Abhinav S 1,540


Advertise | Privacy | Mobile
Web01 | 2.8.140821.2 | Last Updated 14 Jan 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100