Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3240862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T18:08:00+00:00 2026-05-17T18:08:00+00:00

I’m using SQLite3 in a Windows application. I have the source code (so-called SQLite

  • 0

I’m using SQLite3 in a Windows application. I have the source code (so-called SQLite amalgamation).

Sometimes I have to execute heavy queries. That is, I call sqlite3_step on a prepared statement, and it takes a lot of time to complete (due to the heavy I/O load).

I wonder if there’s a possibility to abort such a call. I would also be glad if there was an ability to do some background processing in the middle of the call within the same thread (since most of the time is spent in waiting for the I/O to complete).

I thought about modifying the SQLite code myself. In the simplest scenario I could check some condition (like an abort event handle for instance) before every invocation of either ReadFile/WriteFile, and return an error code appropriately. And in order to allow the background processing the file should be opened in the overlapped mode (this enables asynchronous ReadFile/WriteFile).

Is there a chance that interruption of WriteFile may in some circumstances leave the database in the inconsistent state, even with the journal enabled? I guess not, since the whole idea of the journal file is to be prepared for any error of any kind. But I’d like to hear more opinions about this.

Also, did someone tried something similar?

Thanks in advance.

EDIT:

Thanks to ereOn. I wasn’t aware of the existence of sqlite3_interrupt. This probably answers my question.

Now, for all of you who wonders how (and why) one expects to do some background processing during the I/O within the same thread.

Unfortunately not many people are familiar with so-called “Overlapped I/O”.

http://en.wikipedia.org/wiki/Overlapped_I/O

Using it one issues an I/O operation asynchronously, and the calling thread is not blocked. Then one receives the I/O completion status using one of the completion mechanisms: waitable event, new routine queued into the APC, or the completion port.

Using this technique one doesn’t have to create extra threads. Actually the only real legitimation for creating threads is when your bottleneck is the computation time (i.e. CPU load), and the machine has several CPUs (or cores).

And creating a thread just to let it be blocked by the OS most of the time – this doesn’t make sense. This leads to the unjustified waste of the OS resources, complicates the program (need for synchronization and etc.).

Unfortunately not all the libraries/APIs allow asynchronous mode of operation, thus making creating extra threads the necessarily evil.

EDIT2:

I’ve already found the solution, thansk to ereOn.

For all those who nevertheless insist that it’s not worth doing things “in background” while “waiting” for the I/O to complete using overlapped I/O. I disagree, and I think there’s no point to argue about this. At least this is not related to the subject.

I’m a Windows programmer (as you may noticed), and I have a very extensive experience in all kinds of multitasking. Plus I’m also a driver writer, so that I also know how things work “behind the scenes”.

I know that it’s a “common practice” to create several threads to do several things “in parallel”. But this doesn’t mean that this is a good practice. Please allow me not to follow the “common practice”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T18:08:01+00:00Added an answer on May 17, 2026 at 6:08 pm

    I don’t understand why you want the interruption to come from the same thread and I even don’t understand how that would be possible: if the current thread is blocked, waiting for some IO, you can’t execute any other code. (Yeah, that’s what “blocked” means)

    Perhaps if you give us more hints about why you want this, we might help further.

    Usually, I use sqlite3_interrupt() to cancel calls. But this, obviously, involves that the call is made from another thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I want use html5's new tag to play a wav file (currently only supported
I want to count how many characters a certain string has in PHP, but
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.