Chapter 5. Scenario: Asynchronous 257
Long-running service providers must be able to respond to administrative events.
Therefore, they are often more complex from a logic perspective. If we chose to
implement our calculator as a long-running service, we would create a Windows
Service within Visual Studio.NET that implements the executable under which
our Calculator service will be provided and handles administrative activity such
as startup and shut-down.
A typical pattern for our logic in this case would be:
Start up:
a. Connect to the Queue Manager.
b. Spawn one or more threads to perform work.
c. On notification of failure, spawn new worker threads if possible.
d. On administrative shutdown:
i. Notify all threads to stop.
ii. Close the co ...