Skip to content

Commit

Permalink
更适合 .NET Framework 宝宝的 Stop 方式
Browse files Browse the repository at this point in the history
  • Loading branch information
SlimeNull committed Jun 20, 2024
1 parent a2b30f2 commit 5ad8488
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Sn.ScreenBroadcaster/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,15 @@ _cancellationTokenSource is null ||
#if NET6_0_OR_GREATER
var newClient = await _tcpListener.AcceptTcpClientAsync(cancellationToken);
#else
var newClient = await _tcpListener.AcceptTcpClientAsync();
TcpClient newClient;
using (cancellationToken.Register(() =>
{
_tcpListener.Stop();
}))
{

newClient = await _tcpListener.AcceptTcpClientAsync();
}
#endif
var newClientStream = newClient.GetStream();

Expand Down

0 comments on commit 5ad8488

Please sign in to comment.