private void Button_Click_2(object sender, RoutedEventArgs e) { int check = 0; if (isEmail(registerName.Text) == false) { MessageBox.Show("Email is not correct!"); } else if (registerPass.Password.Trim().Length == 0) { MessageBox.Show("Write a password!"); } else { for (int i = 0; i < userList.Count; i++) { if (registerName.Text == userList[i].username) { MessageBox.Show("Username already taken!"); check = 1; } } if (check == 0) { ServiceReference1.User u = new ServiceReference1.User(); u.username = registerName.Text; u.password = registerPass.Password; ServiceReference1.Service1Client client = new ServiceReference1.Service1Client(); client.addUserAsync(u); client.addUserCompleted += client_addUserCompleted; } } }