Programmatically Stopping Windows Service Hosted Using Topshelf

1,315 views
Skip to first unread message

Nate

unread,
Feb 24, 2011, 10:00:50 AM2/24/11
to topshelf-discuss
I've recently discovered Topshelf for hosting C# windows services. My
question is how can I force the windows service to stop via code and
make sure the service control manager is notified that the service has
stopped. In certain situations, I am catching some specific exceptions
and attempting to stop the service. I have an instance of the Topshelf
ServiceCoordinator and when I call the Stop() method, my internal
service is stopped by Topshelf, but the service still shows as started
when I view it in the Windows Services snap in. Has anyone else run
into this?

Dru Sellers

unread,
Feb 24, 2011, 10:34:33 AM2/24/11
to topshelf...@googlegroups.com
1. Even though your TS service may be stopped, that doesn't mean that the TS host is stopped. The TS Host can support multiple services. We are working on a dashboard that will help users see their hosted services and start/stop them individually.

2. So what you want is a way to STOP the Windows Service (not a Topshelf Service) when you encounter an issue. Is that correct?

-d

Nate

unread,
Feb 24, 2011, 10:37:58 AM2/24/11
to topshelf-discuss
Dru,

Yes, but I am starting to better understand that the TopShelf host is
way more than just a wrapper around some code that I want to run as a
windows service.

Thanks,
Nate

On Feb 24, 10:34 am, Dru Sellers <d...@drusellers.com> wrote:
> 1. Even though your TS service may be stopped, that doesn't mean that the TS
> host is stopped. The TS Host can support multiple services. We are working
> on a dashboard that will help users see their hosted services and start/stop
> them individually.
>
> 2. So what you want is a way to STOP the Windows Service (not a Topshelf
> Service) when you encounter an issue. Is that correct?
>
> -d
>

Dru Sellers

unread,
Feb 24, 2011, 10:46:01 AM2/24/11
to topshelf...@googlegroups.com
Starting with the next release I bet we can come up with something, that will let us better manage a user service's ability to shut the service down. Although, that brings about some interesting security thoughts. hmmm.
-d
Reply all
Reply to author
Forward
0 new messages