Ejemplo n.º 1
0
        protected override void OnStop()
        {
            CDRLogger.Logger.LogInfo("OnStop()");

            if (receiveIndex != null)
            {
                receiveIndex.Stop();
                receiveIndex = null;
            }

            CDRLogger.Logger.LogInfo("KillAccountingThread();");
            KillAccountingThread();

            Webservice.ForceServiceOffline = true;

            // stop service code goes here
            base.OnStop();

            CDRLogger.Logger.LogInfo("serviceMutex.ReleaseMutex();");
            if (serviceMutex != null)
            {
                if (serviceMutex.WaitOne(TimeSpan.Zero, true))
                {
                    serviceMutex.ReleaseMutex();
                    serviceMutex = null;
                }
            }

            if (hostHealthService != null && hostHealthService.State == CommunicationState.Opened)
            {
                hostHealthService.Close(new TimeSpan(0, 0, 10)); // sluiten na max 10 seconden
            }
            if (host != null && host.State == CommunicationState.Opened)
            {
                host.Close(new TimeSpan(0, 0, 10)); // sluiten na max 10 seconden
            }

            CDRLogger.Logger.LogInfo("SMTPLogging.Close();");
            SMTPLogging.Close();
            CDRLogger.Logger.LogInfo("LogUsage.Close();");
            LogUsage.Close();
        }