this.FieldManager.UpdateChildren(...) vs await DataPortal.UpdateChildAsync(theChild, params) #1826
-
I presently have been using this.FieldManager.UpdateChildren in parent business objects however I am not sure how this handles async data portal operations down the hierarchy of objects behind the scenes. I mean it 'seems' to work as expected but I am not sure how threading is treated when calling this.FieldManager.UpdateChildren(...) blocking call. My question is if there is a DataPortal function that is async in the child should you call
or will this have negative results when calling async code?
From what I researched I am leaning towards calling the DataPortal.UpdateChildAsync(...) method on each of of the child(ren) because I have a hunch keeping a blocking call could cause less performance or the like. But any insight into this would be appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
The default behavior should work correctly, but you don't have control. In other words, If you want more control, such as updating multiple child objects in parallel, then you need to loop through the children and use |
Beta Was this translation helpful? Give feedback.
The default behavior should work correctly, but you don't have control.
In other words,
UpdateChildren
ultimately invokes each child's child update operation, and if that operation is async it will wait for the result. This means the operations will run in serial, and will work correctly within the context of a root async method.If you want more control, such as updating multiple child objects in parallel, then you need to loop through the children and use
DataPortal.UpdateChildAsync
, as this does not callWait
and instead returns aTask
so you can execute the operations in parallel or await them individually, or whatever you choose.