private void AcceptFriendRequestOf(Consumer consumer, Label addButtonLabel, Panel singleUserPanel) { BackgroundWorker backgroundWorker = new BackgroundWorker(); backgroundWorker.DoWork += (s, e) => { bool?success = ServerRequest.AcceptFriendRequest(consumer.Id, Consumer.LoggedIn.Id); if (success == true) { if (this.InvokeRequired) { this.Invoke(new Action(() => { this.SetAddFriendButton(consumer, singleUserPanel, "friend"); })); } } else { if (success == null) { MessageBox.Show("Database access denied!"); } } }; backgroundWorker.RunWorkerCompleted += (s, e) => { backgroundWorker.Dispose(); }; backgroundWorker.RunWorkerAsync(); }