diff --git a/ClientApp/Utils/Client.cs b/ClientApp/Utils/Client.cs index a96a2ab..4b347d5 100644 --- a/ClientApp/Utils/Client.cs +++ b/ClientApp/Utils/Client.cs @@ -190,6 +190,9 @@ namespace ClientApp.Utils expectedMessageLength = BitConverter.ToInt32(totalBuffer, 0); } + if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead) || !this.client.Connected) + return; + ar.AsyncWaitHandle.WaitOne(); this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null); } diff --git a/DoctorApp/Utils/Client.cs b/DoctorApp/Utils/Client.cs index 1087346..20b3137 100644 --- a/DoctorApp/Utils/Client.cs +++ b/DoctorApp/Utils/Client.cs @@ -136,6 +136,7 @@ namespace DoctorApp.Utils if (ar == null || (!ar.IsCompleted) || (!this.stream.CanRead) || !this.client.Connected) return; + ar.AsyncWaitHandle.WaitOne(); this.stream.BeginRead(this.buffer, 0, this.buffer.Length, new AsyncCallback(OnRead), null); } diff --git a/DoctorApp/ViewModels/ClientInfoViewModel.cs b/DoctorApp/ViewModels/ClientInfoViewModel.cs index 4b652a5..75de46a 100644 --- a/DoctorApp/ViewModels/ClientInfoViewModel.cs +++ b/DoctorApp/ViewModels/ClientInfoViewModel.cs @@ -77,6 +77,7 @@ namespace DoctorApp.ViewModels ChatToAll = new RelayCommand((parameter) => { + Debug.WriteLine("[CLIENTINFOVIEWMODEL] sending message to all clients"); this.parent?.SendToAllClients(((TextBox)parameter).Text); }); diff --git a/DoctorApp/Views/ClientInfoView.xaml b/DoctorApp/Views/ClientInfoView.xaml index 5057f24..c3e6bca 100644 --- a/DoctorApp/Views/ClientInfoView.xaml +++ b/DoctorApp/Views/ClientInfoView.xaml @@ -57,6 +57,7 @@