Beispiel #1
0
        private IAllyService GetKuaFuService(bool noWait = false)
        {
            IAllyService kuaFuService = null;
            int          clientId     = -1;

            try
            {
                lock (_Mutex)
                {
                    if (string.IsNullOrEmpty(_RemoteServiceUri))
                    {
                        return(null);
                    }

                    if (null == _KuaFuService && noWait)
                    {
                        return(null);
                    }
                }

                lock (_RemotingMutex)
                {
                    if (_KuaFuService == null)
                    {
                        kuaFuService = (IAllyService)Activator.GetObject(typeof(IAllyService), _RemoteServiceUri);
                        if (null == kuaFuService)
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        kuaFuService = _KuaFuService;
                    }

                    clientId = kuaFuService.InitializeClient(this, _ClientInfo);
                    if (null != kuaFuService && (clientId != _ClientInfo.ClientId || _KuaFuService != kuaFuService))
                    {
                        lock (_Mutex)
                        {
                            _KuaFuService        = kuaFuService;
                            _ClientInfo.ClientId = clientId;
                            return(kuaFuService);
                        }
                    }

                    return(_KuaFuService);
                }
            }
            catch (System.Exception ex)
            {
                ResetKuaFuService();
                LogManager.WriteExceptionUseCache(ex.ToString());
            }

            return(null);
        }