I´ve got a windows service and a NotifyIcon-Applicaiton (Sys-Tray) which should communicate with the service. The App should send a command and receive a PORT from the service for a socket which provides the further communication.
The Service overrides the OnCustomCommand Method but I don´t know how to send an answer to the calling-programm.
protected override void OnCustomCommand(int command)
{
switch (command)
{
case 'p':
// SEND Port number
break;
case 's':
// SEND Service Name
break;
case 'n':
// SEND Notification
break;
}
base.OnCustomCommand(command);
}
Notify-Icon-Application
var serviceController = new ServiceController("ATLED Service");
serviceController.ExecuteCommand((int)'p');
There can be different ways you can do that