The Core Technologies Blog

Professional Software for Windows Services / 24×7 Operation

Windows Service Patterns

Windows Service Patterns

Windows Services are special applications designed to run unattended on your PC. A service an do virtually anything its programmer demands, such as reading files, sending email, checking for viruses — whatever.

Yet in the midst of that tremendous diversity, the vast majority of services have a lot in common. With inspiration from Professional NT Services, it is our observation that the majority of windows services can be placed in one of four categories: Server, Agent, Processor or Canary.

  1. Server: Accept and fulfill requests for services and/or resources

    The majority of Windows services implement the Server pattern. They typically act as the proxy/gatekeeper to a well-defined area of the operating system, fulfilling requests as they come in.

    For example:

    • Spooler implements the Print Spooler API. It accepts print requests from desktop applications and negotiates with printers to ensure that they all documents are (eventually) printed.

    • User Profile Service is responsible for loading and unloading user information on behalf of all applications.

    • Windows Event Log records application, system and security events through the Event Log API.

  2. Agent: Perform a task regularly on behalf of a person

    Many services implement the Agent pattern. They run in the background, performing requested tasks at pre-defined times.

    For example:

    • Google Update Service keeps your Google software up to date, applying security patches and other improvements as they become available.

    • The Schedule service works in conjunction with the Windows Task Scheduler, launching each scheduled task at its appointed date and time.

    • Windows Update automatically detects, downloads, and installs of updates for Windows and other Microsoft programs.

  3. Processor: Watches for important events then takes action

    A Processor springs to life in response to a triggering event. It has the autonomy to take action and resolve the issue at hand.

    For example:

    • Windows Time ensures that your PC’s clock is correct, synchronizing it with clients and servers in the network.

    • Background Intelligent Transfer Service opportunistically transfers files in the background when network traffic is low.

    • Bluetooth Support Service supports the discovery and pairing of nearby Bluetooth devices.

  4. Canary: Notify a person (or application) when something important happens

    A Canary is a special kind of Processor. It too watches for important events, but its primary task is to shout loudly instead of taking definitive action.

    For example:

    • Windows Defender Advanced Threat Protection Service helps protect against advanced threats by monitoring and reporting security events that happen on the computer.

    • System Event Notification Service monitors system events and notifies subscribers to COM+ Event System of these events.

    • Connected User Experiences and Telemetry enables features that support in-application and connected user experiences. The service manages the event driven collection and transmission of diagnostic and usage information (used to improve the experience and quality of the Windows Platform) when the diagnostics and usage privacy option settings are enabled under Feedback and Diagnostics.

Many desktop applications follow a Windows Service pattern too!

Those four patterns apply to regular desktop applications as well. Most notably:

  • iTunes enables your Apple devices to play any track from your media library. iTunes is a Server.

  • SyncToy will synchronize two file systems on demand. SyncToy is an Agent.

  • Dropbox watches your file system and copies updated files to the server. Dropbox is a Processor.

  • SpeedFan monitors your computer’s voltage, fan speeds and temperatures and lets you know when something is wrong. SpeedFan is a Canary.

If you are responsible for a legacy/desktop application that aligns with one of the four service patterns, you should consider installing it as a Windows Service. It probably should have been built as a service in the first place!

Posted in Windows Services | Tagged , | Leave a comment

Leave a Reply

Your email address will not be published. Required fields are marked *