简体   繁体   English

SQLite.NET PCL多线程访问MONO

[英]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.Net用于MonodroidMonotouch ,为避免跨线程访问问题,我使用此代码设置了Serialized模式。

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

and this did stop any problems (getting SIGSEVC errors). 并且确实停止了任何问题(获取SIGSEVC错误)。

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. 现在,我已尝试将库代码移至PCL ,因此使用oysteinkrog/SQLite.Net-PCL割草,但设置配置模式的选项似乎不再存在。 Searching through the code I have found that in SQLite.Net.Interop.ISQLiteApi the following line. 通过搜索代码,我发现在SQLite.Net.Interop.ISQLiteApi的以下行。

//        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. 现在,当我的后台线程返回来自Web服务的更新时,我再次在SIGSEVC上收到SIGSEVC错误。

The database connection is shared using a static connection, and all database access via lock(object). 数据库连接是使用静态连接共享的,所有数据库访问都是通过lock(object)进行的。

Questions: 问题:

  1. Is it possible to set the Config to Serialized somehow? 是否可以通过某种方式将Config设置为Serialized?
  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. 似乎最好的解决方法是修改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. 这要求为每个平台创建dll导入和具体实现。

Full details are on the GitHub project here https://github.com/oysteinkrog/SQLite.Net-PCL/issues/35 完整的详细信息在GitHub项目上https://github.com/oysteinkrog/SQLite.Net-PCL/issues/35

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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