Save reference to managed callback in C# wrapper. Fixes event bug.

This commit is contained in:
Joseph Henry
2021-05-25 18:35:58 -07:00
parent ede730de1c
commit b821aee0a5

View File

@@ -85,9 +85,9 @@ namespace ZeroTier.Core
if (managedCallback == null) { if (managedCallback == null) {
throw new ArgumentNullException("managedCallback"); throw new ArgumentNullException("managedCallback");
} }
_unmanagedCallback = OnZeroTierEvent;
int res = Constants.ERR_OK; int res = Constants.ERR_OK;
if ((res = zts_init_set_event_handler(OnZeroTierEvent)) == Constants.ERR_OK) { if ((res = zts_init_set_event_handler(_unmanagedCallback)) == Constants.ERR_OK) {
_unmanagedCallback = OnZeroTierEvent;
_managedCallback = new ZeroTierManagedEventCallback(managedCallback); _managedCallback = new ZeroTierManagedEventCallback(managedCallback);
} }
return res; return res;