Tim,

That would seem a very sensible explanation. I’ve just tried setting my worker 
method to “can be run in preemptive processes” and, as you would have expected, 
it will no longer compile.

So workers intended to do number-crunching and run headless may be marked “can 
be pre-emptive” and those which may want to display their own windows can’t. 
Seems perfectly fair.

My concern about future versions arose because I was bitten by it a while ago. 
I wanted to get costings for anything which had a price of zero. New to 4D, I 
wrote

        QUERY([Items];[Items]price=0)
        APPLY TO SELECTION([Items];GetPriceFromUser)

or some such, where GetPriceFromUser opened a window and demanded an answer. It 
worked like a charm until a later version, which suddenly started throwing a 
bizarre error. It took me a while, and input from the ever-helpful Miyako, to 
track it down to a ban on user interaction within APPLY TO SELECTION. 

Of course, I’d do it very differently now anyway; and as to pistols, I’ll take 
your word for it!

Jeremy

> On 28 Mar 2020, at 22:19, Tim Nevels via 4D_Tech <[email protected]> wrote:
> 
> On Mar 28, 2020, at 2:00 PM, Jeremy Roussak wrote:
> 
>> When Jenner was dithering about vaccination, he was told “Don’t think; try 
>> the experiment”.
>> 
>> I may yet run foul of some hidden gremlin which bares its fangs when 4D19 
>> appears, but I tried the experiment and thus far it works like a dream.
>> 
>> Step 1: at startup, call the worker to get things set up (mostly just 
>> opening a window, miles offscreen, containing a VP area and use DIALOG (…;*) 
>> to show it and let it initialise itself).
>> 
>> Step 2: when required, call the worker to load data into the pre-initialised 
>> VP area, work on it, open a window and display it in a form which allows for 
>> user interaction. When the form is closed, the worker hangs around waiting 
>> for the next usage and the window containing the VP area is still open.
> 
> Good point Jeremy. Rather than talk about things you “think” you know about, 
> but really don’t know about, go do a test and learn about it. Then talk about 
> it. So that’s what I did to make sure my understand was correct. 
> 
> My understanding was that the “no UI for workers” rule only applied to 
> workers running in a preemptive thread. And the only way you can do that is 
> when running compiled and you have specified that the method you are using in 
> CALL WORKER has its “Execution mode” set to “Can be run in preemptive 
> processes”. In this case you can’t have any UI. And 4D enforces this by not 
> even allowing you to compile the database. 
> 
> ...
> It is sort of like the grip safety on the popular 1911 .45 ACP pistols. 

**********************************************************************
4D Internet Users Group (4D iNUG)
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to