Skip to content

Realm Transaction in Xamarin #3335

Answered by nirinchev
dharamhbtik asked this question in Q&A
Discussion options

You must be logged in to vote

Hm, I can see that we're not checking the thread in IsInTransaction, which may explain the issue that you're seeing. Essentially, what I believe is happening is:

  1. You start a write transaction in thread A.
  2. You call AddItem on thread B.
  3. realm.IsInTransaction returns true.
  4. On thread A, you commit/rollback the transaction.
  5. On thread B, you're now trying to add an object outside of transaction.

While the error message is misleading, this wouldn't have worked in any case since you cannot access a Realm instance from multiple threads. So you should review your architecture and make sure to reopen the Realm instance on each thread/scheduler.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@dharamhbtik
Comment options

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