sqlite-net
sqlite-net copied to clipboard
Cancelable Queries (stop the execution of a query via CancelToken)
This is the idea: while this query is running in a task:
connection.Table<MyRecType>()
.CancelToken (tok)
.ToList();
I want another "control task" to be able to abort that query by simply calling CancTokSource.Cancel().
Spoiler: I am already in the process of implementing this feauture: I am checking the status of the cancellation source inside the loops that fetch records, but I am also using the sqlite3_interrupt call to abort any "server-side" processing.
I will issue a pull request when it will be finished. Currently I have implemented cancellable versions of methods of SqliteConnection (methods: DeferredQuery, Query, QueryScalars, and all linq queries initiated by Table<T> (by adding the CancelToken method shown in my example)
I still have to tackle SqliteAsyncConnection.
I will issue a Pull request as soon as possible... If I can avoid doing some "actual" work. (in case someone wants to give it a try or give me some early feedback: https://github.com/csm101/sqlite-net/tree/cancelable_queries)
PS: I already implemented this stuff and I am using it in a production environment. I use it in a "search dialog" where the user sees the records matching the search criteria immediately as he types the criteria itself: whenever the criteria changes while there already is a query in progress, I stop the current query via a cancel token and start the new query with the updated search criteria. I think this is an essential feature if you want your application user interface to be always responsive.