mrwad99
asked on
Calculating ETA from only a percentage of progress
Ah hello.
I have a class function. That function starts a thread, whose sole purpose is to call an SDK function. That SDK function reports progress back via a special CALLBACK function. I would like to be able to report to the user an estimate of how long the SDK function will take to complete.
Now then.
All that I get back from the SDK is a double representing the progress so far; between 0 and 1.0. Not very useful. So I put some thought in, and came up with the idea of having an independent timer running alongside the SDK CALLBACK. Setting the timer up to send a message to me every one second, I could wait until, say, two seconds have passed, then look at how much progress has been made in the CALLBACK. I could then base calculations on the time remaining around the fact that on average, ( progress made in two seconds / 2 ) % progress is made every one second. And go from there...
This sounds a bit messy though. I would need some sort of member variable holding the number of seconds passed as reported by my timer, that the CALLBACK also has access to. Then I would need to protect access to that variable possibly...
Not a serious problem, but I am guessing that someone has come across this kind of issue before.
Any better ideas ?
TIA
I have a class function. That function starts a thread, whose sole purpose is to call an SDK function. That SDK function reports progress back via a special CALLBACK function. I would like to be able to report to the user an estimate of how long the SDK function will take to complete.
Now then.
All that I get back from the SDK is a double representing the progress so far; between 0 and 1.0. Not very useful. So I put some thought in, and came up with the idea of having an independent timer running alongside the SDK CALLBACK. Setting the timer up to send a message to me every one second, I could wait until, say, two seconds have passed, then look at how much progress has been made in the CALLBACK. I could then base calculations on the time remaining around the fact that on average, ( progress made in two seconds / 2 ) % progress is made every one second. And go from there...
This sounds a bit messy though. I would need some sort of member variable holding the number of seconds passed as reported by my timer, that the CALLBACK also has access to. Then I would need to protect access to that variable possibly...
Not a serious problem, but I am guessing that someone has come across this kind of issue before.
Any better ideas ?
TIA
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>>I would need some sort of member variable holding the number of seconds passed as reported
if you can use shared MFC/ATL classes have a look at 'CFileTime' class...
EVEN if class provides methods for managing the date and time values associated with a file You can use it to calculate difference between two times in MiliSeconds / Seconds
eg. have look at CFileTime::Millisecond static data member.. refer this sample...
http://msdn2.microsoft.com/en-us/library/c50awe30(VS.80).aspx
MAHESH
if you can use shared MFC/ATL classes have a look at 'CFileTime' class...
EVEN if class provides methods for managing the date and time values associated with a file You can use it to calculate difference between two times in MiliSeconds / Seconds
eg. have look at CFileTime::Millisecond static data member.. refer this sample...
http://msdn2.microsoft.com/en-us/library/c50awe30(VS.80).aspx
MAHESH
ASKER
Thanks all :)
How reliable is the progress report from the SDK function?
< 0 to 0.5 takes 10 seconds, 0.5 to 1.0 takes 100 seconds !! Think M$ explorers guesstimate of duration left, I wish I had £1 for each time it says 5 seconds to complete and that is shown for x minutes>
(Remember the two pocesses aren't synchronised but that shouldn't be a problem)