Child_XYZ Async no wait server response #922
Comments
You should be able to do this: [UpdateChild]
private async Task Update()
{
await WebApiCall();
} Your child data portal method needs to be |
I test and UI block. Prarent Model
Child Model:
|
And this is with a server-side Blazor UI and a local data portal? |
client-side (blazor assembly) and local data portal.
In UI code as below
|
Client-side Blazor is single-threaded (at the moment) because webassembly is single-threaded. I am guessing that this is where the problem comes from, but I am not sure. However, the data portal itself is able to make an And you are able to call the service for the parent, but not the child? |
I have a repro of this issue. Now to figure out what's happening. |
I take it back - I had a bug in my test code that caused an infinite loop. The data portal works as expected. Working code: using Csla;
using System;
using System.Net.Http;
using System.Threading.Tasks;
namespace BlazorApp1.Client
{
[Serializable]
public class ValueEdit : BusinessBase<ValueEdit>
{
public static readonly PropertyInfo<string> ValueProperty = RegisterProperty<string>(nameof(Value));
public string Value
{
get => GetProperty(ValueProperty);
set => SetProperty(ValueProperty, value);
}
public static readonly PropertyInfo<ValueEdit> ChildProperty = RegisterProperty<ValueEdit>(nameof(Child));
public ValueEdit Child
{
get => GetProperty(ChildProperty);
set => SetProperty(ChildProperty, value);
}
[Fetch]
[FetchChild]
private async Task FetchAsync(string name, [Inject] HttpClient httpClient)
{
Console.WriteLine($"entering {nameof(FetchAsync)}-{name}");
var response = await httpClient.GetAsync("/api/value");
var value = await response.Content.ReadAsStringAsync();
Console.WriteLine($"after readstring {nameof(FetchAsync)}-{name}");
using (BypassPropertyChecks)
{
Value = value;
if (name != "child")
Child = await DataPortal.FetchChildAsync<ValueEdit>("child");
}
Console.WriteLine($"exiting {nameof(FetchAsync)}-{name}");
}
}
} |
Question
If use async in child_XYZ to WebApi , the api no use Csla.
the vm.SaveAsync() no to wait the sever response.
if change child_xyz to sync use .result. the UI block.
Version and Platform
CSLA version: 5.1
OS: Windows,
Platform: Blazor assm ASP.NET Core
The text was updated successfully, but these errors were encountered: