diff --git a/src/Common.CoreLib/WebSocket/ClientConnection.cs b/src/Common.CoreLib/WebSocket/ClientConnection.cs index 6baea85d9..567292b7e 100644 --- a/src/Common.CoreLib/WebSocket/ClientConnection.cs +++ b/src/Common.CoreLib/WebSocket/ClientConnection.cs @@ -49,7 +49,7 @@ namespace System.Net.WebSocket /// 启动连接且尝试握手 /// /// Task - internal async Task StartAsync(CancellationToken cancellationToken) + internal async Task StartAsync() { try { @@ -62,7 +62,7 @@ namespace System.Net.WebSocket State = SocketState.Open; if (OnConnected != null) await OnConnected!.Invoke(new ConnectedEventArgs(this)); - await Task.Run(() => ReadAsync(), cancellationToken); + await ReadAsync(); } catch (SocketException e) { diff --git a/src/Common.CoreLib/WebSocket/WebSocketServer.cs b/src/Common.CoreLib/WebSocket/WebSocketServer.cs index 3cedeb1fd..06043644b 100644 --- a/src/Common.CoreLib/WebSocket/WebSocketServer.cs +++ b/src/Common.CoreLib/WebSocket/WebSocketServer.cs @@ -68,7 +68,7 @@ namespace System.Net.WebSocket OnDisconnected = OnClientDisconnected }; tokenSource.Token.Register(() => { client.Dispose(); }); - await client.StartAsync(tokenSource.Token); + await client.StartAsync(); }, tokenSource.Token); } } diff --git a/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.cs b/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.cs index 9d70b173c..675439a3b 100644 --- a/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.cs +++ b/src/ST.Client.Desktop/UI/ViewModels/Windows/LoginOrRegisterWindowViewModel.cs @@ -15,13 +15,13 @@ namespace System.Application.UI.ViewModels partial class LoginOrRegisterWindowViewModel : WindowViewModel { ServerWebSocket server; - public override void Activation() + public override void Activation() { if (IsFirstActivation) { server = new ServerWebSocket("127.0.0.1", 9910); server.OnClientReceived += handle; - server.Start(); + server.Start(); } base.Activation(); } @@ -48,11 +48,11 @@ namespace System.Application.UI.ViewModels if (IsBind) { await MainThread2.InvokeOnMainThreadAsync(async () => - { - await UserService.Current.BindAccountAfterUpdateAsync(Channel, response.Content!); - var msg = AppResources.Success_.Format(AppResources.User_AccountBind); - Toast.Show(msg); - }); + { + await UserService.Current.BindAccountAfterUpdateAsync(Channel, response.Content!); + var msg = AppResources.Success_.Format(AppResources.User_AccountBind); + Toast.Show(msg); + }); } else {