private void SubscribeForNotifications() { Debug.Assert(_notificationToken == null, "_notificationToken must be null before subscribing."); var managedResultsHandle = GCHandle.Alloc(this); var token = new NotificationTokenHandle(Handle.Value); var tokenHandle = Handle.Value.AddNotificationCallback(GCHandle.ToIntPtr(managedResultsHandle), RealmCollectionNativeHelper.NotificationCallback); token.SetHandle(tokenHandle); _notificationToken = token; }
private void SubscribeForNotifications() { Debug.Assert(_notificationToken == null, "_notificationToken must be null before subscribing."); Realm.ExecuteOutsideTransaction(() => { var managedResultsHandle = GCHandle.Alloc(this); var token = new NotificationTokenHandle(Handle.Value); var tokenHandle = Handle.Value.AddNotificationCallback(GCHandle.ToIntPtr(managedResultsHandle), NotificationsHelper.NotificationCallback); token.SetHandle(tokenHandle); _notificationToken = token; }); }
private void SubscribeForNotifications() { Debug.Assert(_notificationToken == null, "_notificationToken must be null before subscribing."); _realm.ExecuteOutsideTransaction(() => { if (ObjectHandle.IsValid) { var managedObjectHandle = GCHandle.Alloc(this, GCHandleType.Weak); var token = new NotificationTokenHandle(ObjectHandle); var tokenHandle = ObjectHandle.AddNotificationCallback(GCHandle.ToIntPtr(managedObjectHandle), NotificationsHelper.NotificationCallback); token.SetHandle(tokenHandle); _notificationToken = token; } }); }
private void SubscribeForNotifications() { Debug.Assert(_notificationToken == null); var managedResultsHandle = GCHandle.Alloc(this); var token = new NotificationTokenHandle(ResultsHandle); var tokenHandle = NativeResults.add_notification_callback(ResultsHandle, GCHandle.ToIntPtr(managedResultsHandle), RealmResultsNativeHelper.NotificationCallback);; RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { token.SetHandle(tokenHandle); } _notificationToken = token; }
private void SubscribeForNotifications() { Debug.Assert(_notificationToken == null, "_notificationToken must be null before subscribing."); var managedResultsHandle = GCHandle.Alloc(this); var token = new NotificationTokenHandle(ResultsHandle); var tokenHandle = ResultsHandle.AddNotificationCallback(GCHandle.ToIntPtr(managedResultsHandle), RealmResultsNativeHelper.NotificationCallback); RuntimeHelpers.PrepareConstrainedRegions(); try { } finally { token.SetHandle(tokenHandle); } _notificationToken = token; }