public CustomerViewModel GetCustomer(String code) { var customer = _customerServices.GetCustomerByCode(code); CustomerViewModel customerVM = new CustomerViewModel(); customerVM.PartnerService = new BusinessPartnerServiceWrapper(_partnerServices); customerVM.CustomerService = new CustomerServiceWrapper(_customerServices); var result = customerVM.GetCustomerByID(customer.Id); result.AsyncWaitHandle.WaitOne(); result.AsyncWaitHandle.Close(); while (customerVM.InProgress == true) { Thread.Sleep(20); } return(customerVM); }