public ChatRoom(ChatServiceClient client, string roomName, User user) { DontTouchList = false; CurrentChats = new List<Chat>(); InitializeComponent(); MyClient = client; this.Text = roomName; MyUser = user; RoomName = roomName; string[] userlist = null; try { userlist = MyClient.GetUserList(roomName); } catch (Exception) { MessageBox.Show("The service is probably offline"); this.Close(); return; } if (roomName == "The Man Cave") { this.BackColor = Color.Blue; } else if (roomName == "The Kitchen") { this.BackColor = Color.HotPink; } else { this.BackColor = Color.Green; } foreach (var roomUser in userlist) { if (roomUser == MyUser.Username) { DialogResult dialogResult = MessageBox.Show("User with the same username\nalready exists in this room.", "Username Already Exists", MessageBoxButtons.OK); this.Close(); return; } } try { MyClient.AddUserNameToList(MyUser.Username, roomName); } catch (FaultException ex) { MessageBox.Show(ex.Message); } // Create a task and supply a user delegate by using a lambda expression. Task RefreshTask = new Task(() => CollectNewChatInformation()); // Start the task. RefreshTask.Start(); }