Larry Brister
asked on
Windows Service Background Worker
I have a windows service that works locally fine, but times out on startup on the server.
It was suggested that I move the real process out of the startup...and into a background worker.
So...
I seem to be missing something
Testing locally
Project builds and I can do an install
Service starts
I receive an email that it initialized
And another that it reached the OnStart
But when I place an email notification inside the DoWork sub...it never gets there.
But it's not doing the work
I should immediately see 500 records appear in SQL Server.
The code that's in the bwWorker_DoWork sub will start (locally) if I move it back to the OnStart sub
HERES THE CODE
It was suggested that I move the real process out of the startup...and into a background worker.
So...
I seem to be missing something
Testing locally
Project builds and I can do an install
Service starts
I receive an email that it initialized
And another that it reached the OnStart
But when I place an email notification inside the DoWork sub...it never gets there.
But it's not doing the work
I should immediately see 500 records appear in SQL Server.
The code that's in the bwWorker_DoWork sub will start (locally) if I move it back to the OnStart sub
HERES THE CODE
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
bwWorker.WorkerReportsProgress = True
bwWorker.WorkerSupportsCancellation = True
End Sub
Protected Overrides Sub OnStart(ByVal args() As String)
'Me.RequestAdditionalTime(60000)
Try
Dim bw As BackgroundWorker = New BackgroundWorker
bw.RunWorkerAsync()
Catch ex As Exception
Dim erl As ExceptionLogger = Nothing
erl.LogException(ex, ex.Message)
EventLog.WriteEntry(erl.ToXML(ex, ex.ToString), Diagnostics.EventLogEntryType.Error, 911)
End Try
End Sub
Private Sub bwWorker_DoWork(sender As Object, e As DoWorkEventArgs) Handles bwWorker.DoWork
'Get Phone List to monitor from SQL Server
returnedPhoneTable = getPhoneListDT()
'Set initial Thread COunter
threadCounter = 1
'Start Monitoring Phones
getPhoneDataStream()
End Sub
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
DUH! On Me!
Thanks