NT Service with VB: recommendations 
Author Message
 NT Service with VB: recommendations

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.



Tue, 20 Jan 2004 00:01:27 GMT  
 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.



Thu, 22 Jan 2004 21:44:14 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Q: Recommendations for Converting VB App to NT Service

2. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

3. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

4. NT Service: An OLE Control for Creating Windows NT Services in Visual Basic (MSDN article)

5. Help: W2K, IIS, ASP, Component Services, SQL, NT Service and VB

6. Outlook won't start from VB NT Service

7. look if a nt service is runnning (window 2000 server), in vb net

8. How to control NT/2000 service from VB?

9. NT/2000 Service in VB.NET

10. VB 5 and NT 3.51 Service Pack 2 ??

11. Can VB app be made into a NT service

12. NT service + VB + ODBC !?

 

 
Powered by phpBB® Forum Software