Пример #1
0
        protected virtual void Dispose(bool disposing)
        {
            if (!IsDisposed)
            {
                this.AddDeviceCompleted    = null;
                this.DeleteDeviceCompleted = null;
                this.ComClosed             = null;
                this.ComOpened             = null;
                this.SocketClosed          = null;
                this.SocketConnected       = null;

                if (disposing)
                {
                    ControllerManager.RemoveAllController();

                    ChannelManager.RemoveAllChannel();

                    ServiceManager.RemoveAllService();

                    foreach (KeyValuePair <string, IGraphicsShow> show in GraphicsShowManager)
                    {
                        try
                        {
                            show.Value.CloseGraphics();
                        }
                        catch (Exception ex)
                        {
                            this.Logger.Error(true, "", ex);
                        }

                        try
                        {
                            show.Value.Dispose();
                        }
                        catch (Exception ex)
                        {
                            this.Logger.Error(true, "", ex);
                        }
                    }


                    foreach (IRunDevice runDev in DeviceManager)
                    {
                        try
                        {
                            runDev.Exit();
                        }
                        catch (Exception ex)
                        {
                            this.Logger.Error(true, "", ex);
                        }
                        try
                        {
                            runDev.Dispose();
                        }
                        catch (Exception ex)
                        {
                            this.Logger.Error(true, "", ex);
                        }
                    }


                    if (_deviceContainer != null)
                    {
                        _deviceContainer.Dispose();
                    }
                }

                _monitorException.UnMonitor();

                IsDisposed = true;

                Logger.InfoFormat(false, "{0}-{1}", ServerName, "已经停止");
            }
        }