Skip to content

Querying edge case behaviour for instance access after context disposal #2734

Answered by papafe
peppy asked this question in Q&A
Discussion options

You must be logged in to vote

Unfortunately you are correct in saying that this is expected behaviour. When a query needs to be performed, we need to get a hold of a realm handle, that in your case has been disposed. This does not happen with property access, as realm objects have their specific object handle they can use.

Regarding how to deal with realm instances, having a different behaviour for the main thread and background threads. To add to what you already wrote, you don't necessarily need to have a singleton in the main thread, but you can also just create an instance when you need it, in a similar way to what you did with Realm context = realmFactory.CreateContext(). Realms on the main thread are cached, so …

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@peppy
Comment options

@nirinchev
Comment options

@peppy
Comment options

Answer selected by peppy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants