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