Question:You develop a service application named PollingService that periodically calls long-running procedures. These procedures are called from the DoWork method.
You use the following service application code:
Partial Class PollingService
Inherits ServiceBase
Dim blnExit As Boolean = False
Protected Overrides Sub OnStart(ByVal args() As String)
Do
DoWork()
Loop While Not blnExit
End Sub
Protected Overrides Sub OnStop()
blnExit = True
End Sub
Private Sub DoWork()
...
End Sub
End Class
When you attempt to start the service, you receive the following error message: Could not start the PollingService service on the local computer. Error 1053: The service did not respond to the start or control request in a timely fashion.
You need to modify the service application code so that the service starts properly.
What should you do?
 

A Move the loop code into the constructor of the service class from the OnStart method. 

B Move the loop code from the OnStart method into the DoWork method. 

C Drag a timer component onto the design surface of the service. Move the calls to the long- running procedure from the OnStart method into the Tick event procedure of the timer, set the Enabled property of the timer to True, and call the Start method of the timer in the OnStart method. 

D Add a class-level System.Timers.Timer variable to the service class code. Move the call to the DoWork method into the Elapsed event procedure of the timer, set the Enabled property of the timer to True, and call the Start method of the timer in the OnStart method. 

+ Answer
+ Report
Total Preview: 772

Copyright © 2024. Powered by Intellect Software Ltd