tags:

views:

43

answers:

0

Hi,

I have a windows service that is using WCF to communicate with the gui. Unfortunately when I want to restart service from the gui (to reload config) I get the message:

There is already a listener on IP endpoint 0.0.0.0:1111

I'm restarting the service using fallowing code:

        if (sc.Status == ServiceControllerStatus.Running)
        {
            sc.Stop();
            sc.WaitForStatus(ServiceControllerStatus.Stopped);
            sc.Start();
        }

The problem is that service controller have already status on stopped and WCF still didn't release the port. How can i wait for this to happen?