How do you pause and then resume a ServiceApplication ?

Hi All,

I saw in the “Empty Service” template that there are Pause and Resume Events.

Just wondering how you can handle those events…

Fred may be helpful.

Thanks, but I was not thinking of a web app, just a windows service.

Pausing/Resuming the service in the Windows Service Manager causes those events to get called.

Sure, Paul, but how do you handle that in the service App ?

I don’t understand what you mean, then. Do you mean literally “handle” it? If so, just add the event like you would any other event.

Do you mean what should your code do in this situation? Well, that depends on your app. For example if the app has been scanning the drive looking at files, then it should stop doing that when it is paused. For example, you could set/clear property flags that tell your main event loop what it should be doing.

Or do you mean something else?

Yes, Paul , that’s what i mean.

Per Paul’s suggestions, just stop your app from doing what it was when the Pause event is triggered and continue when the Resume event is triggered.

Have you an example, Paul ?

Thanks, Fred

A look at may help.

Thanks Wayne, very interesting example.