Subscription.cs 580 B

12345678910111213141516171819202122232425262728
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace Urho
  4. {
  5. public class Subscription {
  6. internal GCHandle gch;
  7. internal IntPtr UnmanagedProxy;
  8. internal Subscription (Action<IntPtr> proxy)
  9. {
  10. gch = GCHandle.Alloc (proxy);
  11. }
  12. [DllImport (Consts.NativeImport, CallingConvention=CallingConvention.Cdecl)]
  13. extern static void urho_unsubscribe (IntPtr notificationProxy);
  14. public void Unsubscribe ()
  15. {
  16. if (UnmanagedProxy == IntPtr.Zero)
  17. return;
  18. urho_unsubscribe (UnmanagedProxy);
  19. UnmanagedProxy = IntPtr.Zero;
  20. gch.Free ();
  21. }
  22. }
  23. }