public BusListener()
{
// Can't let the GC free these delegates so they must be members
_listenerRegistered = new InternalListenerRegisteredDelegate(_ListenerRegistered);
_listenerUnregistered = new InternalListenerUnregisteredDelegate(_ListenerUnregistered);
_foundAdvertisedName = new InternalFoundAdvertisedNameDelegate(_FoundAdvertisedName);
_lostAdvertisedName = new InternalLostAdvertisedNameDelegate(_LostAdvertisedName);
_nameOwnerChanged = new InternalNameOwnerChangedDelegate(_NameOwnerChanged);
_busStopping = new InternalBusStoppingDelegate(_BusStopping);
_busDisconnected = new InternalBusDisconnectedDelegate(_BusDisconnected);
BusListenerCallbacks callbacks;
callbacks.listenerRegistered = Marshal.GetFunctionPointerForDelegate(_listenerRegistered);
callbacks.listenerUnregistered = Marshal.GetFunctionPointerForDelegate(_listenerUnregistered);
callbacks.foundAdvertisedName = Marshal.GetFunctionPointerForDelegate(_foundAdvertisedName);
callbacks.lostAdvertisedName = Marshal.GetFunctionPointerForDelegate(_lostAdvertisedName);
callbacks.nameOwnerChanged = Marshal.GetFunctionPointerForDelegate(_nameOwnerChanged);
callbacks.busStopping = Marshal.GetFunctionPointerForDelegate(_busStopping);
callbacks.busDisconnected = Marshal.GetFunctionPointerForDelegate(_busDisconnected);
GCHandle gch = GCHandle.Alloc(callbacks, GCHandleType.Pinned);
_busListener = alljoyn_buslistener_create(gch.AddrOfPinnedObject(), IntPtr.Zero);
gch.Free();
}