How to execute asynchronous processing without Server module

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
Taku Izumi
Posts: 70
Joined: Thu Dec 15, 2016 2:03 pm

How to execute asynchronous processing without Server module

Post by Taku Izumi »

Does anyone know how to execute asynchronous processing without Server module?

I want to show a loading image while loading a reusable part that is a large size and takes a long time to draw on the browser.
To do that, I understand that showing the image and loading the part must be in separate threads, which requires asynchronous processing.

This can be achieved by ExecuteAsync Server module, but I don't need I/O to an application database, so I want to reduce the overhead of calling Server module.

If anyone knows a good idea or how to do this, please let me know.

Thanks,
Taku Izumi
User avatar
Dino
Posts: 477
Joined: Fri Jul 19, 2019 7:49 am
Location: Robbinsville, NC
Contact:

Re: How to execute asynchronous processing without Server module

Post by Dino »

I would think that running asynchronous code without the server module, will involve some javascript, meaning, you will need to create your own javascript code, put it in a widget, so you can reuse/call it from your LANSA webpage.

Javascript code like these most likely:
https://developer.mozilla.org/en-US/doc ... ntroducing
BrendanB
Posts: 134
Joined: Tue Nov 24, 2015 10:29 am

Re: How to execute asynchronous processing without Server module

Post by BrendanB »

OR you could do something like:

Code: Select all

Define_Evt Named(StartedLoading)
Define_Evt Named(FinishedLoading)

Mthroutine Name(StartLoadingRP)

#LoadingImage.Visible := True
Signal StartedLoading

Endroutine

Evtroutine Handling(#Com_owner.StartedLoading)

#Com_self.LoadRP

Endroutine

Evtroutine Handling(#Com_owner.FinishedLoading)

#LoadingImage.Visible := False

Endroutine

Mthroutine Named(LoadRP)

* do your loading of RP
Signal FinishedLoading

Endroutine

Why this works:
the Method StartLoadingRP makes the #LoadingImage VISIBLE when the routine ENDS.
the Signal will be processed as soon as possible (its the same as the technique described for javascript).
By using Signals, you give the browser time to show things.

you can also use a #PRIM_TIMR to set a delay before things happen:

Code: Select all

Define_com class(#PRIM_TIMR) Name(#RPTimer) Startup(Manual) Interval(5000)

Mthroutine Named(LoadRP)

* do your loading of RP
#RPTimer.Start

Endroutine

Evtroutine Handling(#RPTimer.Tick)

#RPTimer.Stop
#LoadingImage.Visible := False

Endroutine

In this case, the Timer fires 5000ms after the LoadRP ends, which *may* be the time you need to draw to the screen.

B.
Post Reply