private ITianTiService GetKuaFuService(bool noWait = false) { ITianTiService 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 = (ITianTiService)Activator.GetObject(typeof(ITianTiService), RemoteServiceUri); if (null == kuaFuService) { return(null); } } else { kuaFuService = KuaFuService; } //KuaFuClientContext clientContext = CallContext.GetData("KuaFuClientContext") as KuaFuClientContext; //if (null == clientContext) //{ // CallContext.SetData("KuaFuClientContext", new KuaFuClientContext() { ServerId = ClientInfo.ServerId, ClientId = ClientInfo.ClientId }); //} 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); }