Tuesday, October 10, 2006, 9:32:18 PM, Mohd Radzi Ibrahim wrote: > Thank you guys for the suggestion. That's what I really need. Which one is > better, the sqlite3_interrupt() or sqlite3_progress_handler()? My gut > feeling is that sqlite3_interrupt() should be better since it does not > interfere with the running of the query until it is signaled. Besides, the > progress_handler does not actually give me the right proportion of > completion... Or is there a way I can know proportion of completion from > it?
Suggestion: Create an (atomically accessible) global variable. At the start of your query set it to zero and start a timer. Give sqlite3_progress_handler() a function that simply returns the variable. When the timer expires (or control-C is pressed) atomically set the variable to one. If you use a large value for nOps in sqlite3_progress_handler() the overhead should be very small. e > ----- Original Message ----- > From: "Igor Tandetnik" <[EMAIL PROTECTED]> > To: "SQLite" <sqlite-users@sqlite.org> > Sent: Wednesday, October 11, 2006 8:43 AM > Subject: [sqlite] Re: Terminating long query in C ? >> [EMAIL PROTECTED] wrote: >>> sqlite3_interrupt() has long been used by the sqlite3 shell program. >>> When you press control-C a posix signal handler invokes >>> sqlite3_interrupt() to stop the current query. (This only works on >>> posix, of course.) The original purpose of sqlite3_interrupt() was >>> to support ^C in the shell, and for that purpose the thread >>> restriction >>> was entirely reasonable. >>> >>> It is easy to understand how this use of sqlite3_interrupt() might >>> have escaped the notice of users on non-posix systems. >> >> One can register a Ctrl-C handler on Windows with SetConsoleCtrlHandler. >> But the handler is invoked on a background thread created by the system >> specifically for this purpose, so sqlite3_interrupt couldn't be used >> there, either. >> >> Igor Tandetnik -- Doug Currie Londonderry, NH ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------