Get Time Remaining
Rawden
Posts: 34 Bronze 2
Is it possible to Get the remaing time of a process (like when you hover over the progress bar in the GUI)?
I've seen this function in the documentation, but I can't seem to use it:
RedGate.SQL.Shared.ProgressTask.GetTimeToComplete(Integer) As String
I've seen this function in the documentation, but I can't seem to use it:
RedGate.SQL.Shared.ProgressTask.GetTimeToComplete(Integer) As String
Comments
This code is currently not supported and may change without notice.
However I think if you pass in the percentage of the task it will return you back a string of the estimated time left to get to 100%.
If you pass in a negative percentage completion then it will return back an empty string.
Hope that helps.
Regards
David
Thanks for the reply, I understand what it is supposed to do, but I’m not sure how to reference it. What I mean is, how do I declare it?
If I declare: then it has no reference to any of the objects that are running tasks i.e. my Session object or my SQLProvider object and so I get some weird results back (i.e. 17283.16:26:52)
There is an overload that requires a ProgressTaskMethod and an ICancellable, but that doesn’t help me because I don’t know what they are either.
Thanks,
Rawden.
here is a description of what happens (ish) sorry if I run over ground that you already know...
This is how RedGates Progress Task works (roughly)
For each task that is ICancellable you create a ProgressTask wrapper object.
You then add these sub tasks into a ProgressTask object again. (This allows you to nest the tasks together, as the progress task dialog box is designed to only display upto 5 tasks including the complete operation.)
You can then create an object that adhears to the IProgressTaskExecutor interface, which then in turn runs those tasks in another thread sequentially until they are complete or the user has pressed cancel. There is feedback given according to the style of interface.
So for example the progress dialog box has a dialog box etc, there is also a version that can sit on the status bar (this is what SQL Data Compare uses when you select a new column to sort by) or there is a command line version that is used by our command line versions of all our products.
I guess that this is not how you are integrating into the Toolkit.
Can you explain more as to what you are trying to do?
I am developing a Windows Forms app to DataCompare some tables in two SQL databases. I have that side of things working fine. I use ComparisonSession TableMappings, SQLProvider, BlockExecutor and Database objects. For each of these (where applicable) I set their Status property to reference a callback so I can get feedback on the status and inform user on one of my forms. I have the e.messages and the percentages all working fine. I just wanted to add the time remaining as well. How would I add all these to a Progress Task wrapper object?
So you know
what time the task started
what the current percentage though the task,
what the current time is
If you assume that the tasks are linear then you could simply calculate the length of time left.
Ok that last assumuption is a biggy, but from where you are I cannot see at what else you can do. The ICancelable interface does not tell you the information you need to know.
Hope that helps
David
Ah well, I thought it would be easier to use, but never mind. Thanks for your help David.