コード例 #1
0
        public void StopHosts()
        {
            try
            {
                log.Info("Stopping signals thread...");
                if (this.threadInfo.stop != null)
                {
                    this.threadInfo.stop.Set();
                }

                if (this.serviceConnectionParams != null)
                {
                    Udbus.Core.IStoppable stoppableSignalVisitor = this.serviceConnectionParams.SignalVisitor;
                    stoppableSignalVisitor.Stop = true;
                    this.serviceConnectionParams.SignalConnection.Cancel();
                }

                log.Info("Stopping signals");
                if (this.threadSignalLoop != null)
                {
                    this.threadSignalLoop.Join();
                }
                log.Info("Stopped signals");

                log.Info("Closing hosts...");
                if (this.hosts != null)
                {
                    foreach (System.ServiceModel.ServiceHost host in hosts)
                    {
                        host.Close();
                    }
                }
                log.Info("Disposing hosts...");
            }
            finally
            {
                Udbus.v4v.v4vConnection connectionDispose = this.connection;
                this.InitFields();
                if (connectionDispose != null)
                {
                    log.Info("Disposing connection");
                    connectionDispose.Dispose();
                    log.Info("Disposed connection");
                }
                else
                {
                    log.Info("No connection to dispose");
                }
            }
        }