Waiting for multiple asynchronous calls

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
marco.kam
Posts: 7
Joined: Thu Apr 07, 2016 2:03 am

Waiting for multiple asynchronous calls

Post by marco.kam » Fri Apr 08, 2016 12:46 pm

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?

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Waiting for multiple asynchronous calls

Post by Stewart Marshall » Fri Apr 08, 2016 3:05 pm

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
Attachments
Multiple Server Requests.zip
(11.75 KiB) Downloaded 150 times
Last edited by Stewart Marshall on Fri Apr 08, 2016 6:19 pm, edited 1 time in total.
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

kno_dk
Posts: 110
Joined: Tue Feb 23, 2016 12:00 am

Re: Waiting for multiple asynchronous calls

Post by kno_dk » Fri Apr 08, 2016 4:37 pm

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)

User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Waiting for multiple asynchronous calls

Post by Stewart Marshall » Fri Apr 08, 2016 6:19 pm

Apologies

I've updated the attachment.

Please try again
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au

kno_dk
Posts: 110
Joined: Tue Feb 23, 2016 12:00 am

Re: Waiting for multiple asynchronous calls

Post by kno_dk » Sat Apr 09, 2016 3:54 am

it is okay

Post Reply