Realm accessed from incorrect thread #3339
-
I am trying to refresh realm through background but it is giving exception.
When I am executing above code, it is always throwing exception Line 5 is giving below error :
Line 6 is throwing below error :
As per the documentation, from https://www.mongodb.com/docs/realm-sdks/dotnet/latest/reference/Realms.Realm.html#Realms_Realm_Refresh we have to call the Refresh method in background thread Any way to prevent this incorrect thread exception? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Interesting, I have 3 comments here:
|
Beta Was this translation helpful? Give feedback.
Okay, so the problem is likely related to the async calls - what happens is roughly this:
If you want to do check for Realm changes in the background, it's better to install a synchronization context and rely on notifications. Something like (relies on Nito.AsyncEx.Context):