Hashtable callbacks = new Hashtable (); public static IntPtr EventHandlerAdd(int type, func_ecore_event_handler_add func, IntPtr data) { IntPtr key = ecore_event_handler_add(type, func, data); // Keep a reference so that `func' is not garbage collected. callbacks [key] = func; return val; } public static void EventHandlerRemove(IntPtr key) { if (!callbacks.Contains [key]) throw new Exception ("key is invalid"); ecore_event_handler_remove (key); callbacks.Remove (key); }