SQLite.Net 线程安全吗?

发布于 2024-07-21 05:41:47 字数 231 浏览 3 评论 0原文

我正在询问 .Net 实现 - System.Data.SQLite。 是否有以线程安全方式使用它的指南?

我知道 SQLite 本身可以编译 有或没有线程安全 - 但是System.Data.SQLite 是如何编译的?

I'm asking about the .Net implementation - System.Data.SQLite.
Are there guidelines to using it in a thread-safe manner?

I know SQLite itself can be compiled with or without thread safety - but how was System.Data.SQLite compiled?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

ぇ气 2024-07-28 05:41:47

它不是线程安全的,因此您不能跨线程共享连接对象或类似对象。

自述文件中提到的线程错误修复与使用多个连接(即每个连接)到同一文件的多个线程以及可能产生何种问题或竞争条件有关。

例如,BEGIN 和 BEGIN IMMEDIATE 提到的线程竞争条件会产生不幸的影响,即使一个线程发出 BEGIN,随后发出 BEGIN 的另一个线程仍然可能在第一个线程之前拥有数据库。 这些类型的情况已得到解决。

但.NET 中的数据库连接(oracle、sqlite、ms sql server)不是线程安全的,周围的对象也不是。

It is not thread-safe, so you cannot share connection objects or similar across threads.

The thread bugfixes mentioned in the readme file has to do with multiple threads using multiple connections (ie. one each) to the same file, and what kind of problems or race conditions that might produce.

For instance, the thread race condition mentioned for BEGIN and BEGIN IMMEDIATE had the unfortunate effect that even though a thread issued a BEGIN, another thread that issued a BEGIN afterwards could still end up owning the database before the first one did. These types of situations have been fixed.

But database connections (oracle, sqlite, ms sql server) in .NET are not thread-safe, nor are the surrounding objects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文