diff --git a/ViewModels/MainWindowViewModel.cs b/ViewModels/MainWindowViewModel.cs index a6d0c74..ae687f7 100644 --- a/ViewModels/MainWindowViewModel.cs +++ b/ViewModels/MainWindowViewModel.cs @@ -259,7 +259,7 @@ namespace OnlineUserPool.ViewModels private void SendMessage(Collection clients, List msgModels) { - if (!clients.Any()) + if (!clients.Any() || !msgModels.Any()) { return; } @@ -405,15 +405,22 @@ namespace OnlineUserPool.ViewModels } private void CientDisconnected(EndPoint point) - { - var client = Clients.FirstOrDefault(f => f.IPEndPoint.ToString() == point.ToString()); - if (client != null) + { + dispatcher.Invoke(() => { - dispatcher.Invoke(() => + try { - Clients.Remove(client); - }); - } + var client = Clients.FirstOrDefault(f => f.IPEndPoint.ToString() == point.ToString()); + if (client != null) + { + Clients.Remove(client); + } + } + catch(Exception ex) + { + Log.Information("在CientDisconnected触发以后,删除client时报错了,"+ ex.Message +", " + ex.StackTrace); + } + }); } }