foreach (var user in userIdentifiers) {
var response = await client.sendMsgAsync(
accesscode: paswoord,
userIdentifier: user,
title: "Lovapaanvraag",
body: "Zie .pdf bijlage voor uitgebreide informatie",
senderIdentifier: senderIdentifier,
attachments: jsonString,
coaccount: 0,
copyToLVS: false);
int resultaat = Convert.ToInt32(response);
if (resultaat != 0) geslaagd = false; }
We are working in Blazor wasm.
After filling in a form, an entity gets created and added into the db. After that a .pdf gets created from the form and gets submitted to an external messaging-platform.
This messagingservice calls the above client.SendMsgAsync().
client.SendMsgAsync() is defined on an api we don’t control. It’s a given in this context.
When successful it returns an object-type which contains a 0.
When placing the messagingservice in a different project, I was able to unit-test it. It works.
When running directly in Blazor wasm I get the following error:
System.PlatformNotSupportedException: Cannot wait on monitors on this
runtime.
There definetely is information about this issue out there. If I understand it well, it’s a thread (blocking) issue.
In the end I have to be able to I suggest you extract the async work out of the sync code path and cache the results for use within the sync path.
. Someone else put it as, I somehow need to get rid of the await.
Task.WhenAll() basically only displaces the issue (and provokes loss of information). So I’m quite at a loss how to solve this problem, that shouldn’t be so difficult.
Any suggestions, or new leads, would be greatly appreciated.