SQLite.NET PCL multi thread access MONO

2.6k views Asked by At

I have been using SQLite.Net for Monodroid and Monotouch, To avoid problems with access across threads I used this code to set Serialized mode.

    SQLite.SQLite3.Shutdown();
    SQLite.SQLite3.Config(SQLite.SQLite3.ConfigOption.Serialized);
    SQLite.SQLite3.Initialize();

and this did stop any problems (getting SIGSEVC errors).

I have now attempted to move my library code to PCL, so mow using oysteinkrog/SQLite.Net-PCL but the option to set Config mode seems not to exist anymore. Searching through the code I have found that in SQLite.Net.Interop.ISQLiteApi the following line.

//        Result Config(ConfigOption option);

so the ability to set the config is not implemented.

Now once again I am getting my SIGSEVC error on Monodroid when my background thread returns with updates from a web service.

The database connection is shared using a static connection, and all database access via lock(object).

Questions:

  1. Is it possible to set the Config to Serialized somehow?
  2. or, is there a better way for me to define my connection and database access to avoid this problem.
1

There are 1 answers

0
Sudmanche On BEST ANSWER

It seemed the best way to fix it was to modify the source of the SQLite.Net-PCL. I have done this implementing the missing features.

this required the dll imports and concrete implementations to be created for each platform.

Full details are on the GitHub project here https://github.com/oysteinkrog/SQLite.Net-PCL/issues/35