From d7e9a93bf672ca61154404ba458de014f4e7650f Mon Sep 17 00:00:00 2001 From: XuShanQiXun <3401460572@qq.com> Date: Sat, 7 Jun 2025 13:26:21 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=A9=BA=E6=B6=88=E6=81=AF=E6=A1=86?= =?UTF-8?q?=E4=BB=A5=E6=9B=B4=E6=96=B0=E7=94=A8=E6=88=B7=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在 `MainWindow.xaml.cs` 中,修改了发送数据的逻辑。添加了使用 `Application.Current.Dispatcher.Invoke` 方法清空 `txtMessage` 文本框的代码,以确保在发送数据之前用户界面得到更新。删除了原来的发送数据代码行。 --- chatclient/MainWindow.xaml.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/chatclient/MainWindow.xaml.cs b/chatclient/MainWindow.xaml.cs index ed8f474..1bf6c2e 100644 --- a/chatclient/MainWindow.xaml.cs +++ b/chatclient/MainWindow.xaml.cs @@ -294,7 +294,10 @@ namespace chatclient Client?.Connect(IPAddress.Parse(Server.ServerIP), Server.ServerPort); StartReceive(); Client?.Send(dataBytes); - + Application.Current.Dispatcher.Invoke(() => + { + txtMessage.Clear(); + }); } catch (Exception ex) {