Get service instance in BeforeStoppingService

57 views
Skip to first unread message

Zidad

unread,
Dec 22, 2015, 8:56:31 AM12/22/15
to topshelf-discuss
Hi All,

I'm trying to execute an action (publish a message to RMQ) before the service stops in a BeforeStoppingService(Action<HostStopContext>) handler.

I wanted to use the BeforeStoppingService method because when I try to execute the action in the Stop() of ServiceControl I get a System.Threading.Tasks.TaskCanceledException. (at least, when using ctrl+c to quit from the command line), but now I don't know how to access the instance of the service there. 

Any ideas on how to achieve this?

Thanks!

Wiebe


Reply all
Reply to author
Forward
0 new messages