Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cancelable Queries (stop the execution of a query via CancelToken) #1174

Open
csm101 opened this issue Jun 20, 2023 · 1 comment
Open

Cancelable Queries (stop the execution of a query via CancelToken) #1174

csm101 opened this issue Jun 20, 2023 · 1 comment

Comments

@csm101
Copy link
Contributor

csm101 commented Jun 20, 2023

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 (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)

@csm101
Copy link
Contributor Author

csm101 commented Jul 14, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant