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. But if you set “Execution mode” for the worker method to “Indifferent” or “Cannot be run in preemptive processes” then you can compile and use CALL WORKER to call this method and it will display a UI and work just like any other process. It is just not running in preemptive mode. My understanding proved to be accurate. Here is the example database I created in v17.3 to test this. https://dl.dropboxusercontent.com/s/s9auizcabpnj2in/Worker_with_UI_Example.zip As it is delivered, if you try to compile you get errors. But if you change the “Execution mode” method property of WorkerMethod to “Indifferent” it will complie and you can run it compiled and see the UI from CALL WORKER. Use “Run” menu from Design to Restart Compiled or Restart Interpreted and use Test Application to show a menu bar f and the File menu “Show Simple Dialog” to do just that. If you have a method you want to run in a preemptive thread — and you want it to have a UI — you need to use the CALL FORM to a different process that is NOT running in a preemptive thread and have that process show your UI. That’s the reason the CALL FORM command was created. But you can also use it from a non-preemptive process too, so it’s useful everywhere and is more elegant that the old CALL PROCESS command. It is sort of like the grip safety on the popular 1911 .45 ACP pistols. https://gunbelts.com/blog/grip-safeties/ The weapon won’t fire unless your hand is squeezing the grip. You can drop it — when it is loaded and cocked — and it won’t fire. The 4D compiler is like a grip safety. You can’t fire that worker method in a preemptive thread unless 4D confirms your hand is on the grip — i.e. it checks that there are no UI related commands in the worker method. Then when you “fire" the worker method with CALL WORKER, it fires as expected instead of unexpectedly crashing. Tim ***************************************** Tim Nevels Innovative Solutions 785-749-3444 [email protected] ***************************************** ********************************************************************** 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] **********************************************************************

