You work as the Enterprise application developer at Domain.com. The Domain.com network consists of a single Active Directory domain named Domain.com. All servers in the domain run Windows Server 2003. Your responsibilities at Domain.com include the design and development of application frameworks.
You are currently developing a Microsoft Windows Forms monitoring application for Domain.com. This application is destined to read data in a Microsoft SQL Server 2005 database and display it graphically on a form. All Domain.com users need to be able to:
1. choose the refresh rate for displaying data
2. choose an interval in multiples of one second
To this end you need to reuse a component to meet these requirements without requiring excessive coding.
What should you do?
A.
You need to encapsulate a BackgroundWorker instance in a custom class by wrapping the BackgroundWorker component.
B.
You need to encapsulate a Timer instance in a custom class by wrapping the Timer component.
C.
You need to derive a class from BackgroundWorker by extending the BackgroundWorker component.
D.
You need to derive a class from System.Windows.Forms.Timer by extending the Timer component.
Explanation:
The Timer component needs to be extended in the System.Windows.Forms.Timer class. The Timer component raises a Tick event at intervals specified in the Interval property. If you derive a class from Timer, you in essence allow client applications to set the interval property to multiples of one second.
Incorrect answers:
A: The BackgroundWorker component allows for asynchronous code execution. It is stated pertinently in the question that no excessive coding must be allowed.
B: Wrapping the Timer component is not the solution. It will require you to write code that exposes the functionality of the Timer component.
C: You should not extend the BackgroundWorker component as this component allows one to execute code asynchronously in a background thread and automatically notify the foreground thread when the asynchronous operation completes. However, this involves extra coding is that is required.