Extending <OnPause> and <OnContinue>

Remember that we created a way to indirectly control the flow of service. Using <OnPause> and <OnContinue>, we can write code that will allow us to either block threads from doing work or make them intuitive enough to know whether they should exit or merely delay their processing responsibilities.

Ways to Control Thread Processing

We will implement a couple of different ways to control what the threads do.

Thread Suspension

Our first attempt at thread control will be to use the built-in Thread class method called Suspend. This method will allow us to stop a thread in its tracks, or at least attempt to. A thread suspension can fail, in which case we would end up in a situation that we must code for—a rogue thread. ...

Get Programming Windows® Services with Microsoft® Visual Basic® 2008 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.