private async Task HandleDeleteFromIndexedDb() { BusyOverlayService.SetBusyState(BusyEnum.Busy); var stopwatch = new Stopwatch(); stopwatch.Start(); ItemCount = Articles.Count; foreach (var article in Articles) { await PersistenceService.DeleteAsync <Article>(article); if (!UiUpdates) { continue; } ItemCount = Math.Max(0, ItemCount--); ProcessingTimeMs = stopwatch.ElapsedMilliseconds; if ((ItemCount % 100) == 0 || ItemCount == Articles.Count) { StateHasChanged(); await Task.Delay(1); } } stopwatch.Stop(); ProcessingTimeMs = stopwatch.ElapsedMilliseconds; BusyOverlayService.SetBusyState(BusyEnum.NotBusy); }