mirror of
https://github.com/oliverbooth/VpSharp
synced 2024-11-10 02:55:41 +00:00
Implement IDisposable
This commit is contained in:
parent
656a0b287d
commit
73d0bc8561
@ -4,7 +4,7 @@ using VpSharp.NativeApi;
|
||||
|
||||
namespace VpSharp.Internal;
|
||||
|
||||
internal sealed class Connection
|
||||
internal sealed class Connection : IDisposable
|
||||
{
|
||||
private readonly object _lockObject;
|
||||
private readonly Socket _socket;
|
||||
@ -33,6 +33,12 @@ internal sealed class Connection
|
||||
return (int) NetworkReturnCode.Success;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_timer?.Dispose();
|
||||
_socket.Dispose();
|
||||
}
|
||||
|
||||
private static void ConnectCallback(IAsyncResult ar)
|
||||
{
|
||||
var connection = ar.AsyncState as Connection;
|
||||
@ -83,6 +89,7 @@ internal sealed class Connection
|
||||
var connection = handle.Target as Connection;
|
||||
connection?.BeforeDestroy();
|
||||
handle.Free();
|
||||
connection?.Dispose();
|
||||
}
|
||||
|
||||
private void HandleTimeout()
|
||||
|
Loading…
Reference in New Issue
Block a user