private void InstanceContext_Closed(object sender, EventArgs e) { instanceContext = new InstanceContext(_client); proxy = new DuplexChannelFactory <ITradingForexService>(instanceContext, "TradingService"); ThreadPool.QueueUserWorkItem(new WaitCallback( (obj) => { _tradingServiceClient = proxy.CreateChannel(); })); }
public Core() { _client = new Client(); instanceContext = new InstanceContext(_client); proxy = new DuplexChannelFactory <ITradingForexService>(instanceContext, "TradingService"); ThreadPool.QueueUserWorkItem(new WaitCallback( (obj) => { _tradingServiceClient = proxy.CreateChannel(); })); instanceContext.Closed += InstanceContext_Closed; instanceContext.Faulted += InstanceContext_Faulted; }
/// <summary> /// Login user to database /// </summary> /// <param name="email"></param> /// <param name="password"></param> public void LoginUser(string email, string password) { while (_tradingServiceClient == null) { ; } while (true) { try { if (_tradingServiceClient.LoginUser(email, password)) { UserEmail = email; break; } else { throw new ArgumentException("Wrong email or password"); } } catch (ArgumentException) { throw; } catch (EndpointNotFoundException) { throw new EndpointNotFoundException("Server is currently offline"); } catch (Exception) { ThreadPool.QueueUserWorkItem(new WaitCallback( (obj) => { _tradingServiceClient = proxy.CreateChannel(); })); } } }