I am using the SQLite.NET PCL library for my WinRT projects with the
SQliteAsyncConnection
class, which offers async versions of the classic SQLiteConnection
methods. However, on the project's Github page the following is stated:
Please be aware that the
Task.Run
pattern used inSQLiteAsyncConnection
can be considered an anti-pattern (libraries should not provide async methods unless they are truly async). This class is maintained for backwards compatibility and for use-cases where async-isolation is handy
Why is using Task.Run
in this case considered an anti-pattern? This allows the developer to achieve exactly the goal he needs - to run the database access code on a separate thread while the app stays responsive to user input. Would it be better to manually write Task.Run
snippet each time and not use the async version of the class altogether?
What are the potential issues and setbacks of this pattern?