Threading Problem in Windows Service

  • Thread starter Thread starter microsoft.public.dotnet.framework.performance
  • Start date Start date
M

microsoft.public.dotnet.framework.performance

All,

Have any of you seen a thread created and Thread.Start() called without
error, but then the thread is seemingly never actually started?

I have a class defined in a VB.NET 2003 Windows Service project. Each
instance of this particular class needs to run in its own thread (though
right now there is only one instance under consideration). So, the
constructor is coded as given below:

[begin code]
Public Sub New()
Try
' General Initialization...
<this works>
' Open the text log file for output...
<this works>

' Create a new thread for this instance of the class
mThread = New System.Threading.Thread(AddressOf Me.pWorker)
' Start the thread
mThread.Start()
Catch ex As Exception
' Write the exception to the Application section of the Event
Log
EventLog.WriteEntry(<the entry>)
End Try
End Sub
[end code]

(I have a private method named pWorker that loops until the service is
stopped, at which time it returns from the method to exit the thread.)

The problem is that no exception is being thrown in the constructor, yet
pWorker is never called (I have logging code to check this).

The kicker is that this code works just fine on my machine (WinXP Pro SP2).
However, when we start the service on a customer's server (running on Win2K
Server), general initialization occurs and the text log file is created, but
the thread seems to never start. But at the same time, no exceptions are
being thrown.

Any thoughts??

Thanks,
Phil
 
The service's start mode is Automatic, but I am manually starting and
stopping the service (for testing) by NET START <servicename> and NET STOP
<servicename>.

Thanks,
Phil

chanmmn said:
Are you start the service manually or automatic?

chanmm

microsoft.public.dotnet.framework.performance said:
All,

Have any of you seen a thread created and Thread.Start() called without
error, but then the thread is seemingly never actually started?

I have a class defined in a VB.NET 2003 Windows Service project. Each
instance of this particular class needs to run in its own thread (though
right now there is only one instance under consideration). So, the
constructor is coded as given below:

[begin code]
Public Sub New()
Try
' General Initialization...
<this works>
' Open the text log file for output...
<this works>

' Create a new thread for this instance of the class
mThread = New System.Threading.Thread(AddressOf Me.pWorker)
' Start the thread
mThread.Start()
Catch ex As Exception
' Write the exception to the Application section of the Event
Log
EventLog.WriteEntry(<the entry>)
End Try
End Sub
[end code]

(I have a private method named pWorker that loops until the service is
stopped, at which time it returns from the method to exit the thread.)

The problem is that no exception is being thrown in the constructor, yet
pWorker is never called (I have logging code to check this).

The kicker is that this code works just fine on my machine (WinXP Pro
SP2). However, when we start the service on a customer's server (running
on Win2K Server), general initialization occurs and the text log file is
created, but the thread seems to never start. But at the same time, no
exceptions are being thrown.

Any thoughts??

Thanks,
Phil
 
No. In fact, we haven't even tried after Reboot (i.e., in Automatic mode).
We simply installed the service, started it, and ran across the problem I
detailed.

Thanks,
Phil
 
Back
Top