I'm guessing I've got this a little wrong.
I am initializing two DxRichText controls and I think I have something wrong in how I have this set up. But I don't see what. I am trying to have this loading occur in parallel with other initialization.
I have the following methods:
private Task InitializeRichText(DxRichEdit editor, Organization? org,
RichText? src, RichTextModel model)
{
if (org == null || src == null)
return editor.NewDocumentAsync().AsTask();
model.RichText = src;
model.BlobUrl = BlobService.GetBlobUrl(src.OpenXmlFilename);
return LoadUrlAsync(editor, model.BlobUrl);
}
private async Task LoadUrlAsync(DxRichEdit editor, string url)
{
using (var httpClient = new HttpClient())
{
using (var response = await httpClient.GetAsync(url))
{
if (response.IsSuccessStatusCode)
{
await using (var stream = await response.Content.ReadAsStreamAsync())
{
await editor.LoadDocumentAsync(stream, DocumentFormat.OpenXml);
}
}
}
}
}
Important item: NewDocumentAsync()
and LoadDocumentAsync()
return a ValueTask
(not a Task).
In my OnInitializedAsync()
I have the following (with lots of other code in between):
var listRichTasks = new List<Task>();
await Task.Yield();
listRichTasks.Add(InitializeRichText(RichEditDesc, _organization,
_organization?.Description, Model.Description));
listRichTasks.Add(InitializeRichText(RichEditNews, _organization,
_organization?.News, Model.News));
// this call is never returning
Task.WaitAll(listRichTasks.ToArray());
What do I have wrong?