Red Gate forums :: View topic - Get Time Remaining
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation
SQL Toolkit Previous Versions
SQL Toolkit Previous Versions forum

Get Time Remaining

Search in SQL Toolkit Previous Versions forum
Post new topic   Reply to topic
Jump to:  
Author Message
Rawden



Joined: 07 Nov 2006
Posts: 27

PostPosted: Fri Jan 11, 2008 10:56 am    Post subject: Get Time Remaining Reply with quote

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
Back to top
View user's profile Send private message Send e-mail
david connell



Joined: 21 Nov 2005
Posts: 207

PostPosted: Wed Jan 16, 2008 1:54 pm    Post subject: Reply with quote

Hi Rawden,
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
Back to top
View user's profile Send private message
Rawden



Joined: 07 Nov 2006
Posts: 27

PostPosted: Wed Jan 16, 2008 5:51 pm    Post subject: Reply with quote

Hi 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:
Code:
Dim x As New RedGate.SQL.Shared.ProgressTask
debug.Print x.GetTimeToComplete(e.Percentage)

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.
Back to top
View user's profile Send private message Send e-mail
david connell



Joined: 21 Nov 2005
Posts: 207

PostPosted: Wed Jan 16, 2008 6:07 pm    Post subject: Reply with quote

Hi 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?
Back to top
View user's profile Send private message
Rawden



Joined: 07 Nov 2006
Posts: 27

PostPosted: Wed Jan 16, 2008 6:22 pm    Post subject: Reply with quote

Hi David,

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?
Back to top
View user's profile Send private message Send e-mail
david connell



Joined: 21 Nov 2005
Posts: 207

PostPosted: Wed Jan 16, 2008 6:30 pm    Post subject: Reply with quote

OK it sounds like you have wrapped up your own Progress Task Dialog box...
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
Back to top
View user's profile Send private message
Rawden



Joined: 07 Nov 2006
Posts: 27

PostPosted: Wed Jan 16, 2008 7:15 pm    Post subject: Reply with quote

Yes. I wasn't aware that I could use a standard dialog box, so I made my own. I'm not sure I could calculate a Time Remaining just based on how long it had been running because some of the tasks take longer than others. For example, connecing to a database would take a lot less time than say the comparision or the Execution.

Ah well, I thought it would be easier to use, but never mind. Thanks for your help David. Very Happy
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group