Question Problem with looping in Windows Service

Hitz

Member
Joined
Jul 22, 2011
Messages
9
Programming Experience
Beginner
Hi,
I have problem with looping in Windows Service.

Here is some sample code:

Protected Overrides Sub OnStart(ByVal args() As String)
AddHandler timer.Elapsed, AddressOf Me.OnElapsedTime
timer.Interval = sValue
timer.Enabled = True
End Sub
Private Sub OnElapsedTime(ByVal source As Object, ByVal e As ElapsedEventArgs)
run_timer()
End Sub
Protected Overrides Sub OnStop()
timer.Enabled = False
End Sub

Public Sub run_timer()
//some declarations
For Each row_loop As DataRow In ds_loop.Tables("loop").Rows
//do something in database
Next
End sub

The problem is that each time when timer is elapsed only first element of the loop is being executed and ithe rest are not executing.

Can any one tell me what is the problem??

Thank You.
 
You could see in event log if an exception is logged. If an exception is thrown the service stops and the message is logged in event log.
This may also be helpful: How to: Debug Windows Service Applications
Using a regular application for debugging first could be a good idea before moving it to a service.
 
Hi,
Yes i executed the same program in regular application.It was working fine. But when i am trying the same in windows services it was not working properly and also when i checked the log it was showing that service started succesfully.
 
Back
Top