-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTorrentStatus.cs
51 lines (39 loc) · 1.14 KB
/
TorrentStatus.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using System;
using System.Runtime.InteropServices;
namespace Tsunami.Core
{
using TorrentStatusHandle = HandleRef;
public class TorrentStatus : IDisposable
{
#region PInvoke
[DllImport("TsunamiBridge", CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr TorrentStatus_Create();
[DllImport("TsunamiBridge", CallingConvention = CallingConvention.StdCall)]
public static extern void TorrentStatus_Destroy(TorrentStatusHandle handle);
#endregion PInvoke
TorrentStatusHandle handle;
public TorrentStatus()
{
IntPtr h = TorrentStatus_Create();
handle = new HandleRef(this, h);
}
public TorrentStatus(IntPtr h)
{
handle = new HandleRef(this, h);
}
public void Dispose()
{
CleanUp();
GC.SuppressFinalize(this);
}
private void CleanUp()
{
TorrentStatus_Destroy(handle);
handle = new HandleRef(this, IntPtr.Zero);
}
~TorrentStatus()
{
CleanUp();
}
}
}