I am working with data source, using Local Database where i use foreach list on all Ids of the database.
if i add the block delete in datasource, on return of web api the delete dont work.
Follow print in attachment
this way it works, but I need to validate the API return.
This is a synchronization issue. The real issue that you are facing is that the
Web API is very much slower that the
ForEach loop. What actually happens is that the loop is faster than the
Web API and it goes into the second and third loop before the API respond.
See this demo
Thanks, i understood!
If i add a timer before execute delete the problem can is solved?
Or have other solution for this?
One thing that I would consider is creating a recursive function. A recursive function is a function that calls itself until its planned execution is complete. Are you familiar with that concept?
In this type of set up you could call the function which calls the API and in the vendue section you can call the function again. This ensures the function/api call is not ran again until the first API call is complete.
- note: using recursive functions can lead to issues when you are dealing with very large data sets OR when you don’t know the length of the list to iterate upon (i.e. Your app needs to know how many times to run the function before moving on to other tasks). If you don’t know the length of the. data set, your function could run forever leading to a crash. If you are dealing with large datasets and do know the number, you may want to block the user from further interacting with the app until the entire task is finished.
I never used this function.
But in the munner demo there is an example.
I will test this recommendation and i return with an answer.