UndercoverDeveloper on Fri, 30 Jun 2017 11:44:35
I'm working on an App wich uses Xamarin.Forms and Azure App Service. The user must explicitly execute a data sync. When the user starts a data sync a lot of this methods are executed to get the current data from the server:
My problem: The application can get into an inconsistent state. For example when the user closes the App before the data sync is completed. In this state the App is not usable.
To make it easier to understand: Let's assume i have a table "ToDoItem" and "ToDoCategory". The user starts a data sync. The data sync runs and the all ToDoItems are successfully retrieved . In the next step the data sync will get the ToDoCategories (another call to PullAsync) but before this the user closes the app. Now i have all ToDoItems but no ToDoCategories. But the App is not useable with no ToDoCategories. This is a really simple example. The data structure is much more complex in the real project. There are a lot of dependencies between the entities.
It is no solution to log the sync error / cancellation and prompt the user at the next app start for another sync. Assume on the next app start the user has no internet connection and cannot perform a data sync. I cannot lock the app unitl the next successful data sync.
Is there a way to run multiple PullAsync operations in a transaction?