Need some advice on how to throw a TimeoutException after a certain time has passed and the method to Send Data to my fireStore db still not complete, due to internet loss or any other unexpected issue.
using the Plugin.CloudFirestore Plugin by f-Miyu.
The Code to send data to server.
public async Task BackUpNotes(UserNotes n)
{
await CrossCloudFirestore.Current.Instance.Collection(FTxts.Notes).Document(n.ID)
.SetAsync(new {
n.ID,
n.Title,
n.Details,
n.CreatedDate,
n.IsStarred,
n.LastEditDate,
});
}
//Called Here
private async Task BackUpNotes()
{
if (IsBusy) return;
IsBusy = true;
int c = 0;
var answer = await Application.Current.MainPage.DisplayAlert("Confirmation", "Back Up Current Notes?", "Yes", "No");
if (answer)
{
foreach (var item in NotesCollection)
{
await CloudService.CS.BackUpNotes(item);
item.IsBackedUp = true;
await PlannerDataService.UpdateNote(item);
c++;
ToastMessageShort($"{c}/{NotesCollection.Count} Saved");
}
await GetNotes();
}
IsBusy = false;
}