Page 1 of 1
Waiting for multiple asynchronous calls
Posted: Fri Apr 08, 2016 12:46 pm
by marco.kam
When getting data from the server, we can do calls like this:
Code: Select all
#ServerMethod1.ExecuteAsync
#ServerMethod2.ExecuteAsync
We can also define the processing that happens after each asynchronous call is complete:
Code: Select all
Evtroutine Handling(#ServerMethod1.Completed)
* Do some processing here after call to ServerMethod1 complete
Endroutine
Evtroutine Handling(#ServerMethod2.Completed)
* Do some processing here after call to ServerMethod2 complete
Endroutine
How can I wait for both calls to ServerMethod1 and ServerMethod2 (or maybe many asynchronous calls) to complete before I process the results?
Re: Waiting for multiple asynchronous calls
Posted: Fri Apr 08, 2016 3:05 pm
by Stewart Marshall
Hi Marco
This is easily achieved in RDML by storing the data request instances in a collection.
Rather than doing this in every component, a simple reusable part can be made and then reused wherever necessary. It can also be given Scope(*Application) and shared across a whole application, so the requests can be coded wherever you like.
In the attached example, the monitor collects the requests and when all have completed it fires an event. In this case a button is hidden when the requests are submitted and then shown again on completion.
Regards
Re: Waiting for multiple asynchronous calls
Posted: Fri Apr 08, 2016 4:37 pm
by kno_dk
Hi Stewart.
I am trying to import your export, but I get some errors. here are the log for the import:
Object Import Facility Started 08-04-16 08:32:28 (08:32:28)
This procedure is being logged into file C:\PROGRA~2\LANSA\X_WIN95\X_LANSA\x_DEM\importlogs\Import_9.log (08:32:28)
Export Version 004 found. (08:32:28)
Loading list of files to be imported from directory/shared folder C:\Users\KNO\Downloads\MultipleServerRequests\. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxbdf.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxf60.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxf03.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxfcc.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxfbs.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxfrd.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxf62.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxf74.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxfan.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxf02.asf. (08:32:28)
Loading format information from file C:\Users\KNO\Downloads\MultipleServerRequests\lxxfcr.asf. (08:32:28)
Intermediate import file name is C:\Users\KNO\AppData\Local\Temp\exp80e3b.tmp. (08:32:28)
Converting data from file LXXBDF for import to the LANSA environment. (08:32:28)
136 records converted from file LXXBDF. (08:32:28)
Converting data from file LXXF60 for import to the LANSA environment. (08:32:28)
2 records converted from file LXXF60. (08:32:28)
Converting data from file LXXF03 for import to the LANSA environment. (08:32:28)
ERROR: <Allow Type Changes> is not set, existing External Resource identifier "XDEMOW_43" cannot be deleted and import of Field / Component identifier "XDEMOW_43". (08:32:28)
2 records converted from file LXXF03. (08:32:28)
Converting data from file LXXFCC for import to the LANSA environment. (08:32:28)
2 records converted from file LXXFCC. (08:32:28)
Converting data from file LXXFBS for import to the LANSA environment. (08:32:28)
2 records converted from file LXXFBS. (08:32:28)
Converting data from file LXXFRD for import to the LANSA environment. (08:32:28)
150 records converted from file LXXFRD. (08:32:28)
199 records converted from file LXXFRD. (08:32:28)
Converting data from file LXXF62 for import to the LANSA environment. (08:32:28)
4 records converted from file LXXF62. (08:32:28)
Converting data from file LXXF74 for import to the LANSA environment. (08:32:28)
2 records converted from file LXXF74. (08:32:28)
Converting data from file LXXFAN for import to the LANSA environment. (08:32:28)
ERROR: <Allow Name Changes> is not set, existing name "xDemoWebLoading" of Field / Component identifier "XDEMOW_43" cannot be changed to "xDemoWebHandlingMultipleServerRequests". (08:32:29)
2 records converted from file LXXFAN. (08:32:29)
Converting data from file LXXF02 for import to the LANSA environment. (08:32:29)
8 records converted from file LXXF02. (08:32:29)
Converting data from file LXXFCR for import to the LANSA environment. (08:32:29)
22 records converted from file LXXFCR. (08:32:29)
Import file C:\Users\KNO\AppData\Local\Temp\exp80e3b.tmp has been deleted. (08:32:29)
Object Import Facility Ended 08-04-16 08:32:29. 2 fatal errors were detected. 0 warnings were issued. (08:32:29)
Re: Waiting for multiple asynchronous calls
Posted: Fri Apr 08, 2016 6:19 pm
by Stewart Marshall
Apologies
I've updated the attachment.
Please try again
Re: Waiting for multiple asynchronous calls
Posted: Sat Apr 09, 2016 3:54 am
by kno_dk
it is okay