"BobAchgill " <an*******@disc ussions.microso ft.com> wrote in message
news:04******** *************** *****@phx.gbl.. .
So that leaves the question...
Where do I stick in my FTP processing code??
OnStart gets called when your service is started and returning from
this method signals to the Service Control Manager that your service
has started successfully. What I'd suggest is a System.Timers.T imer
that fires once and only once that you start in OnStart.
When this timer fires, call your main processing routine that can do
whatever it needs to, but I'd recommend using Thread.Sleep() to
leave a gap in processing; don't use the Timer (I've had them stop
on me for no readily apparent reason).
OnStop gets called when your service is asked to stop and returning
from this method says to the Service Control Manager "you can kill
this one now"; beware if your processing could be interrupted part
way through!
(a starting point)
Private m_bShutDownComp lete as Boolean = False
Private m_bShutDownRequ ested as Boolean = False
Sub OnStart()
Me.tmrStarter.E nabled = True
End Sub
Sub OnStop()
m_bShutDownComp lete = False
m_bShutDownRequ ested = True
Do While m_bShutDownComp lete
Thread.Sleep( 500 )
Loop
End Sub
Sub tmrStarter_Elap sed( ... ) _
Handles tmrStarter.Elap sed
Me.tmrStarter = False
RunProcess()
End Sub
Sub RunProcess()
Do While Not m_bShutDownRequ ested
' Do Something Useful
. . .
Thread.Sleep( 500 ) ' or whatever
Loop
m_bShutDownComp lete = True
End Sub
HTH,
Phill W.