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:
await this.ISyncTable.PullAsync(queryId, query, cancellationToken).ConfigureAwait(false);
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.
Edit:
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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…