Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

Pause WinService??

I have a Windows Service I created in VB.Net

How do I add code to allow a pause in the service?
Avatar of Giuseppe Pizzuto
Giuseppe Pizzuto
Flag of Italy image

You can't just pause it by itself: during the pause, the service will not run...
Create another service that Stops/Starts the first or, better, pause its execution for a while:

system.threading.thread.sleep (100)

waits for 100 milliseconds...
Avatar of Larry Brister

ASKER

gpizzuto

My apologies...I wasn't clear
Once installed and the service is running...I want the ability in the Services Window to Pause it.
I don't understand...
Open your command prompt (WIN+R, type 'services.msc' without quotes and hit ENTER)
Select your service, right-click with your mouse and SUSPEND (or PAUSE, I don't know the exact translation, I'm italian)

Is that what you meant ?
If you need it in command-prompt, type:

net pause [your_service_name]
If you don't want to use net commands,
use the command 'SC' in your command prompt.
You can call it also in your vb code.
Type SC /? for sintax
gpizzuto

I understand what your saying
There IS NO Pause when I right click.

Is that something I set in the VB when I build it?

This is my first foray into Windows Services.
ASKER CERTIFIED SOLUTION
Avatar of Giuseppe Pizzuto
Giuseppe Pizzuto
Flag of Italy image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's it, thanks.

I've been in Web and Winforms forever

Just now getting back familiar with Win Services