简体   繁体   中英

SQLite.NET PCL multi thread access MONO

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM