Parallel data getting
This commit is contained in:
parent
059088121e
commit
81c9030daf
11 changed files with 808 additions and 8 deletions
|
@ -17,7 +17,6 @@
|
|||
<MudButton Variant="Variant.Filled" OnClick=StartLearning Color="Color.Primary">Start learning!</MudButton>
|
||||
</MudContainer>
|
||||
|
||||
|
||||
<MudContainer Class="justify-center d-flex">
|
||||
@if (Charecters != null)
|
||||
{
|
||||
|
@ -98,19 +97,28 @@
|
|||
StateHasChanged();
|
||||
}
|
||||
|
||||
async void LoadAllChunksIntoLocalStorage()
|
||||
async Task LoadAllChunksIntoLocalStorage()
|
||||
{
|
||||
isLoading = true;
|
||||
for (int i = 0; i < numOfChunks; i++)
|
||||
string[] jsonChunks = new string[numOfChunks];
|
||||
|
||||
Parallel.For(0, numOfChunks, async (i)=>
|
||||
{
|
||||
string? jsonChunk = await httpClient.GetStringAsync($"Data/Normalized_chunk_{i.ToString("000")}.json");
|
||||
await Task.Delay(10*i);
|
||||
jsonChunks[i] = await httpClient.GetStringAsync($"Data/Normalized_chunk_{i.ToString("000")}.json");
|
||||
|
||||
if (string.IsNullOrEmpty(jsonChunk)) continue;
|
||||
if (string.IsNullOrEmpty(jsonChunks[i])) return;
|
||||
|
||||
await localStorage.SetItemAsync($"Normalized_chunk_{i.ToString("000")}.json", jsonChunk);
|
||||
await localStorage.SetItemAsync($"Normalized_chunk_{i.ToString("000")}.json", jsonChunks[i]);
|
||||
savedChunks = i + 1;
|
||||
});
|
||||
|
||||
while (jsonChunks.Any(x => x == null))
|
||||
{
|
||||
await Task.Delay(1);
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
isLoading = false;
|
||||
isSavedLocally = true;
|
||||
StateHasChanged();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue