Having an update in a form when executing code

Hi,
this is a problem I would like to solve !

When you have a method in a button, doing a long loop on elements, I want to be able to make some changes in the UI, just to let people knows something append.

I don’t want to use a separate process, I want to execute the method in the form context.
But I want to animate some pictures or widgets in the same form in order to give fun or represent what’s happening.

Any idea for that ?
I tried to launch a worker, I call in the loop, the worker asking to update some elements in the form, with CALL FORM. But all the posted messages are read only once my method is finished…

As far as I know, the form only gets updated when the form’s method has a chance to complete a cycle. Nothing else happens within a process during a cycle of one of the process’s methods. The new Progress Wheel looks like an exception, but it pauses when a button runs this code:
While (not(Shift down))
idle
End while

On the other hand, this will produce a change in the window.
While (Not(Shift down))
SET WINDOW TITLE(String(Current time);Current form window)
End while

Can you do something using MESSAGE?

[]34447291;“Teletype like…”[/]

Dear,

A long shot and not tested in your case, but I use
Call Process (-1) to update globals on a form in another process.
For this purpose it works, but in case calling this from the same process…
Worth a try.

Best regards
Magnus Torell

Hi thanks for all your reply and to get a try, but this do not fit my goal.
A method running in the same process as the form, interacting and updating a image object or a widget in the same form.

I love animations, and for good UI it is very interesting to have the progress animation in the same form.
And I don’t want to launch a new process, as all the context is in the from, this is an extra work to do so.

Hi Olivier,

You can achieve something like that using a web area, since the web area is managed separately to the form. However you need to have a way to set the web area visible before starting execution.

For a long running process I have an animated gif displayed in a small web area on the form. When the user clicks the button that will start execution it unhides the web area and then calls CALL PROCESS to signal to the form that execution should start. At the end of execution the web area is hidden again.

Alternately if you can have your whole form as a web area you can make whatever interface changes you like during execution by executing javascript in the web area. (I have a form that works like this too)

Execute your task with a worker and you will be able to animate a picture at the same time ?

: Olivier GRIMBERT

I tried to launch a worker, I call in the loop, the worker asking to
update some elements in the form, with CALL FORM. But all the posted
messages are read only once my method is finished…

yes. Think about the other way around…

the process controlling the GUI (window) must be cooperative, that’s an OS requirement.
Even Notebooks have these days 4 virtual cores or even 4 native cores. Think about to use them.

So instead of moving the graphic code to a worker, you should start to move the processing code into a worker, having the “main” process doing only user interface.
This way, your code runs preemptive and everything gets smoother and faster.

The worker is preemptive and does the real stuff.

Yes, I understood that this is what you explicitly don’t want to do:

: Olivier GRIMBERT

I don’t want to use a separate process, I want to execute the method
in the form context.

But that’s exactly why workers was created.

: Olivier GRIMBERT

I don’t want to use a separate process, I want to execute the method
in the form context.

separate process does not necessarily prohibit you from running code in the form context.

the worker (separate process) can do the heavy lifting via CALL WORKER,

while the UI can be updated in the form context via CALL FORM,
perhaps every seconds or so, invoked from the worker.

you would do that by passing the window reference and method name (minimum) plus some other parameters to the worker, for it to run some code in the form context.

Hi all and thanks for your replies…

: Adam STORCK

You can achieve something like that using a web area, since the web
area is managed separately to the form. However you need to have a
way to set the web area visible before starting execution.

Yes for sure, but a web area is “heavy” to load, even a good solution explained by Keisuke here (in the middle) :
http://4d.1045681.n5.nabble.com/Progress-Bar-On-A-Form-td5111247.html

: Thomas MAUL

But that’s exactly why workers was created.
You’re right Tomas. I was expecting a possibility to have the method in the form process and call a worker making the UI modification, but it is impossible in fact, as the method in the form is cooperative.

I checked and it is confirmed :slight_smile:

So, no other choice than to do the main method in

  • a process and do some “POST OUTSIDE CALL”.
  • a worker and CALL WORKER which will call a FORM CALL.

It sounds good then.

: Olivier GRIMBERT

Yes for sure, but a web area is “heavy” to load, even a good solution
explained by Keisuke here (in the middle) :
http://4d.1045681.n5.nabble.com/Progress-Bar-On-A-Form-td5111247.html

Sorry, broken link :frowning:

Thomas,

: Thomas MAUL

you should start to move the processing code into a worker, having
the “main” process doing only user interface.

I was thinking about this (updating an older database) and are you suggesting here that we use the Application process for the UI?