public void InitalizeServerProxy()
        {
            _eventAggregator.GetEvent<MessageUpdateEvent>().Publish(new MessageUpdateEvent { Message = "Starting M3Service" });
            StartServer();
            Thread.Sleep(2000);
            _uiDispatcher.Invoke(new Action(() =>
            {
                try
                {
                    if (_serverProxy != null)
                    {
                        DisposeServerProxy();
                    }
                    _eventAggregator.GetEvent<MessageUpdateEvent>().Publish(new MessageUpdateEvent { Message = "M3Service initializing" });

                    _serverProxy = new LCTServerMessageProxy();
                    // _fLogService.Info("Mars start Initalize Server...");
                    _serverProxy.Initalize();
                    //_fLogService.Info("Mars Initalize Server finish!");
                    _serverProxy.HandshakeServerProviderInterval = 10000;
                    _serverProxy.NotifyRegisterErrEvent += OnNotifyRegisterErrEvent;
                    //_serverProxy.CompleteConnectAllController += OnCompleteConnectAllController;
                    _serverProxy.EquipmentChangeEvent += OnEquipmentChangeEvent;

                    _eventAggregator.GetEvent<MessageUpdateEvent>().Publish(new MessageUpdateEvent { Message = "M3Service initialization completed" });

                    if (RegisterToServer())
                    {

                    }
                    else
                    {

                    }
                }
                catch (Exception ex)
                {
                    //_fLogService.Error("ExistCatch:Mars Initalize Server exception:" + ex.ToString());
                }
            }));
        }
        /// <summary>
        /// 销毁服务对象
        /// </summary>
        private void TerminateServerProxy()
        {
            if (_proxy == null)
            {
                return;
            }
            _proxy.NotifyRegisterErrEvent -= new NotifyRegisterErrEventHandler(OnNotifyRegisterErrEvent);

            _proxy.CompleteConnectAllController -= new EventHandler(OnCompleteConnectAllController);
            _proxy.CompleteConnectEquipment -= new ConnectEquipmentEventHandler(OnCompleteConnectEquipment);

            _proxy.EquipmentChangeEvent -= new EventHandler(OnEquipmentChangeEvent);
            _proxy.Terminate();
            _proxy = null;
        }
 private void TerminateServerProxy()
 {
     //Application.Current.Dispatcher.Invoke(new Action(() =>
     //    {
     DispatcherHelper.UIDispatcher.Invoke(new Action(() =>
     {
         if (_serverProxy == null)
         {
             return;
         }
         try
         {
             _serverProxy.NotifyRegisterErrEvent -= new NotifyRegisterErrEventHandler(OnNotifyRegisterErrEvent);
             _serverProxy.CompleteConnectAllController -= new EventHandler(OnCompleteConnectAllController);
             _serverProxy.CompleteConnectEquipment -= new ConnectEquipmentEventHandler(OnCompleteConnectEquipment);
             _serverProxy.EquipmentChangeEvent -= new EventHandler(OnEquipmentChangeEvent);
             _serverProxy.Terminate();
             _serverProxy = null;
         }
         catch (Exception ex)
         {
             _fLogService.Error("ExistCatch:TerminateServerProxy exception:" + ex.ToString());
             _serverProxy = null;
         }
     }));
 }
 private void InitalizeServerProxy()
 {
     //Application.Current.Dispatcher.Invoke(new Action(() =>
     //    {
     DispatcherHelper.UIDispatcher.Invoke(new Action(() =>
     {
         try
         {
             if (_serverProxy != null)
             {
                 TerminateServerProxy();
             }
             #region 初始化服务
             _serverProxy = new LCTServerMessageProxy();
             _fLogService.Info("Mars start Initalize Server...");
             _serverProxy.Initalize();
             _fLogService.Info("Mars Initalize Server finish!");
             _serverProxy.HandshakeServerProviderInterval = 10000;
             _serverProxy.NotifyRegisterErrEvent -= OnNotifyRegisterErrEvent;
             _serverProxy.NotifyRegisterErrEvent += OnNotifyRegisterErrEvent;
             _serverProxy.CompleteConnectAllController -= OnCompleteConnectAllController;
             _serverProxy.CompleteConnectAllController += OnCompleteConnectAllController;
             _serverProxy.CompleteConnectEquipment -= OnCompleteConnectEquipment;
             _serverProxy.CompleteConnectEquipment += OnCompleteConnectEquipment;
             _serverProxy.EquipmentChangeEvent -= OnEquipmentChangeEvent;
             _serverProxy.EquipmentChangeEvent += OnEquipmentChangeEvent;
             #endregion
         }
         catch (Exception ex)
         {
             _fLogService.Error("ExistCatch:Mars Initalize Server exception:" + ex.ToString());
         }
     }));
 }