When a Topshelf hosted app runs on a console, not as service, you stop it by pressing Ctrl+C. That is handled by Topshelf for you (wrapping the CancelKeyPress
of Console
). Is it possible to register a handler for other keys with Topshelf so that I might control some small details of my service when the key m is pressed or maybe F5 (all while the console window has focus of course and all not available when running as a service)?
Services are not generally designed to support interactive control, so there is no way to do this with Topshelf. If you need to control your service, the use of a separate mechanism is recommended, such as a socket (either raw, or via HTTP self-hosted, etc.) or message-based communication to the service.