private void ChatClient_OnDeleteMessageOccurred(object sender, Guid messageID) { ChatMessageControl message = this.MessageControls.FirstOrDefault(msg => msg.Message.ID.Equals(messageID)); if (message != null) { message.DeleteMessage(); } }
private async void ChatClient_OnDeleteMessageOccurred(object sender, Guid messageID) { await this.Dispatcher.InvokeAsync <Task>(async() => { await this.messageUpdateLock.WaitAsync(); ChatMessageControl message = this.MessageControls.FirstOrDefault(msg => msg.Message.ID.Equals(messageID)); if (message != null) { message.DeleteMessage(); } this.messageUpdateLock.Release(); }); }
private async void ChatClient_OnDeleteMessageOccurred(object sender, ChatDeleteMessageEventModel deleteEvent) { await this.Dispatcher.InvokeAsync <Task>(async() => { await this.messageUpdateLock.WaitAndRelease(() => { ChatMessageControl message = this.MessageControls.FirstOrDefault(msg => msg.Message.ID.Equals(deleteEvent.id)); if (message != null) { message.DeleteMessage(deleteEvent.moderator?.user_name); if (ChannelSession.Settings.HideDeletedMessages) { this.MessageControls.Remove(message); } } return(Task.FromResult(0)); }); }); }