-
This is probably more of a blazor issue than CSLA, but since the code revolves around csla I figured I'd ask here. I'm creating an business object with this call. fagj = await applicationContext.GetRequiredService<IDataPortal<FezWeb.BizObj.FA_FAGJ>>().CreateAsync(); The create calls a common object to retrieve a journal # and the value is assigned to the journalNo property. The issue we're running into is the code returns before the command object completes it's process. The next line of code relies on the journal property being filled in. Adding a Task.Delay between the lines of code solves the issue. Is their a better approach to waiting for processes to complete. Here is my create code using (BypassPropertyChecks)
} Mike |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 2 replies
-
adding the code below within the create solves it, but not sure if this is the best approach. Task T = Task.Run(async () => await SetDefaults()); |
Beta Was this translation helpful? Give feedback.
-
Please post your whole create method with declaration. |
Beta Was this translation helpful? Give feedback.
-
I'd guess without seeing the rest of the project this issue is almost certainly because the async code is not properly written to flow up and down the stack. I'd guess somewhere in the stack there is something like an async void method or an async Task method called without an await operator. As soon as such a stack encounters "real" async code it is going to immediately return. The solution given was to turn the async code into synchronous code which further gives me the feeling that this is the case. What is the solution if I'm right? That would completely be dependent on the overall codebase and what is trying to be done. To me this looks like a common issue of not having the asynchronous code completely flow up and down the call stack and nothing to do with CSLA per se. |
Beta Was this translation helpful? Give feedback.
-
We're using net 9.0. the create is a void, let me try changing that, can't believe i missed that. "private async void DataPortal_CreateAsync([Inject] Csla.IDataPortal<CO_Headers> Dal, " Let me try changing it. |
Beta Was this translation helpful? Give feedback.
-
That solved it, can't believe I missed something so simple. Thanks for your help. |
Beta Was this translation helpful? Give feedback.
We're using net 9.0. the create is a void, let me try changing that, can't believe i missed that. "private async void DataPortal_CreateAsync([Inject] Csla.IDataPortal<CO_Headers> Dal, "
Let me try changing it.