diff --git a/DS4Windows/DS4Control/UdpServer.cs b/DS4Windows/DS4Control/UdpServer.cs index 93076f5..7e87fd8 100644 --- a/DS4Windows/DS4Control/UdpServer.cs +++ b/DS4Windows/DS4Control/UdpServer.cs @@ -177,6 +177,7 @@ namespace DS4Windows SocketAsyncEventArgs args = new SocketAsyncEventArgs(); args.RemoteEndPoint = clientEP; args.SetBuffer(packetData, 0, packetData.Length); + args.Completed += ClearSentData; try { udpSock.SendToAsync(args); } catch (Exception e) { } } @@ -634,6 +635,7 @@ namespace DS4Windows SocketAsyncEventArgs args = new SocketAsyncEventArgs(); args.RemoteEndPoint = cl; args.SetBuffer(outputData, 0, outputData.Length); + args.Completed += ClearSentData; try { udpSock.SendToAsync(args); } catch (SocketException ex) { } } @@ -642,5 +644,11 @@ namespace DS4Windows clientsList.Clear(); clientsList = null; } + + private void ClearSentData(object sender, SocketAsyncEventArgs args) + { + args.Dispose(); + args = null; + } } }