
NT Service with VB: recommendations
I would suggest that you not check for the minute being = 20 or 40 but rather >=
20/40; if the first task doesn't finish until 6:21, you'll not get the second.
That's if you really insist on doing it this way - have you looked at the NT
scheduling options? You can get it just to fire up the process you want when
you want it, without having an essentially-idle task{*filter*} around all the
time. NT will do it, so 2000 surely does it?
Incidentally, you should read MSDN article Q175948. Form your own conclusion,
but at least read the article.
Hercules Gunter
Quote:
> Hello,
> I created an NT service with vb6 Ent, SP4. My target machne runs Win 2K
> Server
> or Pro with SP2. I used the NTSVROCX component to create the service.
> Basically, the service consists of a form with a Timer on it. The timer
> interval is
> set to 25,000, so it should fire every 25 seconds.
> When it fires, it checks to see whether it is 6 am and if it is, it performs
> certain
> activities. Afterwards, it checks to see whether the minutes past the hour
> are
> 0, 20 or 40 and if so, performs other activities. Since the multiple
> activities
> that this event may perform can take a certain time I disable the timer when
> the
> Timer event fires and renable it when it is done. Lastly, I have an error
> handler
> that closes things up and logs the error to a text file. The algorithm goes
> like this:
> sub Timer_Timer
> Define error handler
> Timer1.enabled = False
> Get the current time into local variable
> If Hour of Time is 6 am then
> Consult Oracle database for any pending messages. If found, then
> create appropriate text file.
> End If
> If Minutes of Time is at 20 min interval (0, 20, 40) then
> Log onto FTP server
> Send pending messages (as txt files)
> Receive any new messages (also as txt files)
> Log off FTP server
> Log send and receive activities in Oracle database
> End If
> Timer1.enabled = True
> Exit
> Error Handler:
> Log error in text file
> Exit
> Notice that if an error occurs, I don't re-enable the Timer component. I
> would
> greatly appreciate any recommendations, as i am approaching the end of this
> project and would like to make it robust as possible.
> Thank you for your time.
> Salvador
> Remove the "v" from my email to get my real e-mail address.