![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Does exist a timer function Hello to everyone, is there a timer function in vbs/vb that give me the opportunity, for example in a loop, to set a time, say 5 minutes, and then start an event? I created a script to do a ping to an host: what I'd like to do programmatically is start a ping every 5 minutes or so. Someone has any idea? -- Regards, Marco Mangiante |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Does exist a timer function "Marco Mangiante" <MarcoMangiante@xxxxxx> wrote in message news:17ED8595-9E4D-4562-8DD2-B690B24DA759@xxxxxx Quote: > Hello to everyone, > > is there a timer function in vbs/vb that give me the opportunity, for > example in a loop, to set a time, say 5 minutes, and then start an event? > > I created a script to do a ping to an host: what I'd like to do > programmatically is start a ping every 5 minutes or so. > > Someone has any idea? > > -- > Regards, > > Marco Mangiante do YourPingFunction wscript.sleep 300000 loop |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Does exist a timer function Marco Mangiante wrote: Quote: > is there a timer function in vbs/vb that give me the opportunity, for > example in a loop, to set a time, say 5 minutes, and then start an event? > As has already been said, you can use sleep and then "wake up" to send your ping. But, if you are courageous enough, or foolhardy enough, to use a 3rd party control, then you could make use of a "real" system timer. One big advantage of a system timer is that your script can run (doing "real work") and then get interrupted periodically by the system timer. One such timer, packaged as an actX object, is Steve McMahon's SSubTmr control, found here: http://www.vbaccelerator.com/home/VB...er/article.asp Note that the title of that page is "Subclassing without Crashes", but the SSubTmr control also contains a timer. Here is how to use Steve's timer in script (assuming you have downloaded it and registered it: Dim oTMR : Set oTMR + WScript.CreateObject("SSubTimer.CTimer", "oTMR_") Set the interval and turn on the timer: oTMR.Interval = 2000 Your timer event handler: Sub oTMR_ThatTime() ' timer event... ..do some stuff End Sub When finished, turn off your timer: oTMR.Interval = 0 ' make sure timer is OFF... Set oTMR = nothing That's all there is (for this one). There are probably others. There are also "high-resolution" timers, but that's another subject. cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) p.s. Cautionary note: It almost goes without saying, BUT... the code in your timer event handler should be very brief -- and particularly so if the timer interval is short. For example, if your timer event handler takes a while to run, and if the interval is so short that another timer event fires while the event handler is still not finished with processing the previous event, then you have overlapping event processing, which cascades down into chaos. If this happens, it is unlikely you will ever recover, and the symptom you will see shortly is "out of stack space"... |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Egg Timer | Vista General | |||
| RC2 Egg Timer | Vista General | |||
| BUG: Redirecting function contents to a file truncates function lines at the width of the console | PowerShell | |||
| Egg timer on XP | Vista General | |||
| Egg Timer | Vista General | |||