[Asynchronous] How to run slow sql and update UI after finish

I have a Traditional web app. In Top Page of this web app, there is a icon (1) display on top right of header. The icon can have 2 different colors depends on the return value from an sql statement (2):

+ If sql statement (2) return a number > 0 then icon (1) is red icon

+ If sql statement (2) return a number =0 then icon (1) is green icon

=> I will run  sql statement (2) in Preparation Action of Top Page to display for icon (1)

*** But i have problem that the sql statement (2) take long time to complete => It affects the user experience

Question: Is there a way for me to run the sql statement (2) asynchronously and update icon (1) after finish?

Hi  Cuong Cao,

As in the Traditional Application, You need the values from a Sql Query to update Icon Color,

1) Instead of Calling the Query in the Screen Preparation ,Call it and Save locally on some button click in the Previous Screen and pass it as an Input parameter to the next Screen --you don't need to call the Query in Screen Preparation

2) Usually Page Render would be in Sync with the Preparation Flow End ,No Issue with User Experience even if the sql query takes time to Render---Use a Screen Loading Icon Or Image (with Boolean value set to  display property) and Show the Screen Only after the Query returned the value (setting Boolean to true)

  Hope it Helps!!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.