|
-
Dec 15th, 2007, 12:00 PM
#1
Thread Starter
New Member
[2005] VB.NET Timer help..
I need some help with a program I'm making. It's a program that will shut down your computer when a download is finished. It's going to be simple, all you do is write the download time in a box and when it counts down to 0 the computer will shut down, but since the download speed will go up and down it will add 30 minutes to the specified time.
All I need help with is how to make the timer and counter, how to make them work with the textbox. So when someone writes a number it will count down when he press "Start".
-
Dec 15th, 2007, 01:01 PM
#2
Lively Member
Re: [2005] VB.NET Timer help..
Use process.start() method.
"Remember there is always someone who knows more than us out there"
-
Dec 15th, 2007, 01:16 PM
#3
Re: [2005] VB.NET Timer help..
If you have a timer, then the interval is in ms. It would probably make sense for people to enter the time in seconds, so set the interval to 1000x whatever they enter. However, there is a maximum size to the interval, though it is pretty big. You'd want to make sure you don't go over that. If you want intervals larger than the limit, then you'd have to divide the desired time into X number of intervals of smaller sizes, and have a counter such that every time it counted down, you'd decrease the number of intervals by one.
Alternatively, you could set the timer interval to 1000, and keep count of the number of time ticks until it exceeds the number of seconds that the user entered. This would have some slight advantage, since you can show the count on the screen. Of course, if you want to show it counting down, then it would be the total - the current count.
My usual boring signature: Nothing
 
-
Dec 15th, 2007, 09:49 PM
#4
Re: [2005] VB.NET Timer help..
I don't really see how using a Timer for this makes sense. Surely the user would want the system shut down WHEN the download finished, not some arbitrary amount of time afterwards or perhaps even beforehand. You should not use a Timer at all and simply invoke the shutdown code WHEN the download completes.
It doesn't matter how you're performing the download; there will be a simple way to know when it's done. If you're calling a synchronous method then you know it's done when the method returns. If you're using an asynchronous method then there will be a callback or event to tell you.
-
Dec 15th, 2007, 10:44 PM
#5
Thread Starter
New Member
Re: [2005] VB.NET Timer help..
Ah, okay. But how would I do it without a timer? Sorry, I'm pretty new to VB
-
Dec 15th, 2007, 10:52 PM
#6
Re: [2005] VB.NET Timer help..
Like I said, execute the code to shutdown the system when the download completes. The question of how to shutdown the system has been asked and answered many times, so a forum search will tell you that.
As for how to know when the download has finished, I also said that it would depend on how you were performing the download in the first place. You have n't shown us that so we can't tell you how to know when it's done.
-
Dec 15th, 2007, 10:54 PM
#7
Frenzied Member
Re: [2005] VB.NET Timer help..
What I'd like to know is how you'd do it with a timer. *rimshot*
Seriously though, which kind of download are you talking about? Surely there must be some way to know what it is finished, no? When the download is finished, however, you are going to want to use Process.Start()
This may be of some help:
http://vbforums.com/showpost.php?p=2399228&postcount=3
-
Dec 15th, 2007, 11:21 PM
#8
Thread Starter
New Member
Re: [2005] VB.NET Timer help..
It will shut down the computer when a download is finished using Mozilla, IE, Opera or any other browser. Sorry for not mentioning that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|