public virtual void Stop()
{
// do any pre-stop processing.
try
{
OnServerStopping();
}
catch (Exception e)
{
m_serverError = new ServiceResult(e);
}
// close any listeners.
List<ITransportListener> listeners = m_listeners;
if (listeners != null)
{
for (int ii = 0; ii < listeners.Count; ii++)
{
try
{
listeners[ii].Close();
}
catch (Exception e)
{
Utils.Trace(e, "Unexpected error closing a listener. {0}", listeners[ii].GetType().FullName);
}
}
listeners.Clear();
}
// close the hosts.
lock (m_hosts)
{
foreach (ServiceHost host in m_hosts)
{
if (host.State == CommunicationState.Opened)
{
host.Abort();
}
}
m_hosts.Clear();
}
}
#endregion