Forum Libraries, Components, and Plugins

Realm DB - exception thrown for no apparent reason

EitanEEitanE Member ✭✭

I have a refresh command in a Xamarin page, and for some reason, Realm throws a RealmInvalidTransactionException when it finishes. In their documentation they wrote about the exception:

An exception, thrown when trying to write data to the Realm outside a Transaction or when trying to create a transaction on a Realm that is opened as read-only.

This is my refresh command:

ICommand refreshCommand = new Command(async () =>
    refreshView.IsRefreshing = true;

    // Refresh everything
    var w = summaryViewModel.Articles[0];

    // wait for articles to finish loading to stop loading indicator
    await Task.Run(() =>
            while (w == summaryViewModel.Articles[0]) ;
        catch (ArgumentOutOfRangeException e)
            while (summaryViewModel.Articles.Count < 5) ;
    refreshView.IsRefreshing = false;

While debugging, I noticed that the exception is only thrown right after the refresh command finishes. No object is trying to access the DB after it, and nothing actually happens after the command finishes its job, so I don't understand why the exception would be thrown.

Sign In or Register to comment.