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.
ref class PollingService : public ServiceBase {
public :
static bool blnExit = false;
protected :
override void OnStart(String= args) {
do {
DoWork();
} while (!blnExit);
}
override void OnStop() {
blnExit = true;
}
private :
void DoWork() {}
};
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 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. 

C Move the loop code from the OnStart method into the DoWork 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. "A Composite Solution With Just One Click" - Certification Guaranteed 296 Microsoft 70-536 Exam 

+ Answer
+ Report
Total Preview: 1126

Copyright © 2024. Powered by Intellect Software Ltd