Hello.

I've created a windows service application. I am also creating a UI for it.

I want to add a "Stop Service" button in my UI app, but am unsure how to
code the shut down within the service app. Call Dispose()?

Thanks in advance,

Mike

Re: How to shut down my windows service by Lee

Lee
Thu Aug 11 13:42:39 CDT 2005

mike wrote:
> Hello.
>
> I've created a windows service application. I am also creating a UI for it.
>
> I want to add a "Stop Service" button in my UI app, but am unsure how to
> code the shut down within the service app. Call Dispose()?
>
> Thanks in advance,
>
> Mike

In the OnStop event quit doing what you are doing.
Close files. Stop listening. Stop timers. Exit loops. Etc.
You probably created a main process thread in the OnStart
event handler. Cause that thread to stop.

Then when you return from OnStop the service process exits.

Re: How to shut down my windows service by Erick

Erick
Thu Aug 11 16:47:07 CDT 2005

> I want to add a "Stop Service" button in my UI app, but am unsure how
to
> code the shut down within the service app. Call Dispose()?
Look at service controller:

ServiceController controller = new ServiceController("MyService");
controller.Start();
controller.Stop();


Don't forget to reference System.ServiceProcess.

HTH
Erick Sgarbi
www.blog.csharpbox.com



"mike" <milop@slomins.com> wrote in message
news:#H2gPOqnFHA.1996@TK2MSFTNGP10.phx.gbl:

> Hello.
>
> I've created a windows service application. I am also creating a UI for it.
>
> I want to add a "Stop Service" button in my UI app, but am unsure how to
> code the shut down within the service app. Call Dispose()?
>
> Thanks in advance,
>
> Mike


Re: How to shut down my windows service by Lee

Lee
Thu Aug 11 17:13:10 CDT 2005

Erick -

Just so as not to confuse Mike....

The code you provided would reside in UI app.
Mike asks what needs to be done in the SERVICE APP.
"but am unsure how to
code the shut down within
the service app"

- Lee