Execute the request asynchronously
Member of HTTP Request (PRIM_WEB.HttpRequest)
The ExecuteAsync method is used to execute the HTTPRequest asynchronously. Once the request is submitted, processing will continue, ensuring that user interaction isn't blocked. The use of asynchronous requests is recommended over synchronous requests.
In this example, a weather API is executed asynchronously, returning the data as a JSON object. When the completed event fires, the result is processed.
Mthroutine Name(GetWeather) Access(*Private) Define_Map For(*Input) Class(#prim_alph) Name(#Resource) Define_Com Class(#PRIM_WEB.HttpRequest) Name(#Request) #Request.URL := "http://api.openweathermap.org" + #Resource #Request.ExecuteAsync Evtroutine Handling(#Request.Completed) If (#Request.Response *IsNot *null) Case (#Request.Response.Status) When (= 200) #Com_owner.Update( #Request.Response.JSON.RootItem ) Otherwise #Com_owner.UpdateForFailure( #Request ) Endcase Endif Endroutine Endroutine
Febuary 18 V14SP2