You create a Windows service named myService that queries a table named Orders in a Microsoft SQL Server database. You want myService to check every 30 seconds for new rows in Orders.
You create the following method in myService:
private void ProcessOrders(object source,
ElapsedEventArgs eventArgs) {
// Logic to process Orders table goes here.
}
You need to add additional code to myService to invoke the ProcessOrders method. What should you do?
A.
To the OnStart method, add the following code segment:
Timer myTimer = new Timer();
myTimer.Elapsed += new
ElapsedEventHandler(ProcessOrders);
myTimer.Interval = 30000;
myTimer.Enabled = true;
B.
To the OnCustomCommand method, add the following code segment:
Timer myTimer = new Timer();
myTimer.Elapsed += new
ElapsedEventHandler(ProcessOrders);
myTimer.Interval = 30000;
myTimer.Enabled = true;
C.
To the OnStart method, add the following code segment:
Timer myTimer = new Timer();
myTimer.Elapsed += new
ElapsedEventHandler(ProcessOrders);
myTimer.Interval = 30000;
myTimer.AutoReset = true;
D.
To the OnCustomCommand method, add the following code segment:
Timer myTimer = new Timer();
myTimer.Elapsed += new
ElapsedEventHandler(ProcessOrders);
myTimer.Interval = 30000;
myTimer.AutoReset = true;