Look at ServiceBase.OnCustomCommand(Int32) Method

Create a ServiceController

ServiceController Controller = new ServiceController("MyWindowsService");

Validate the status is running e.g. Controller.Status == ServiceControllerStatus.Running and if running pass an int to work with OnCustomCommand

The service has to listen for requests. You need to decide how this is done. In the early days you used nt rpc calls, and still can. But adding a rest api or gRPC to the service is more modern.

This is easy to do with .net core or net 6. You WPF would just use WebClient to call the service.





Created: 12/12/2021 11:34:16
Page views: 25,243