oysteinkrog/SQLite.Net-PCL — pull request #60 by IanMercer (2014-09-26 03:32:03+00:00)
Title: Implement CancellationToken support for async method calls (Issue#55)

Issue#55 requested support for CancellationTokens. This is important because otherwise a database request once queued up as a Task will always need to run to completion even if, by the time it gets to run, and by the time it acquires the global lock, it is no longer needed. For example, the user may have scrolled some listview further to display new cells or has moved to a different page in the application.

With this PR, the caller can use a CancellationTokenSource to cancel a pending operation and, if the task hasn't started executing yet, or the lock hasn't been acquired yet, the database call will not happen, saving valuable resources.

A further refinement would be to use an async locking mechanism that also supported cancellations (but that's a much bigger change than this fairly simple addition of new method signatures and a couple of checks in the cancellation token).