NetTalk Central

Author Topic: How to donot generate multiple threads of the same page  (Read 4693 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
How to donot generate multiple threads of the same page
« on: November 18, 2022, 07:39:48 AM »
I have a Mem form that sest some filters and shows a browser with address to visit (lat/lon)
The form has a button wich calls another mem form with a map in it to shows the icons of the address on the map.
When there are many icons the form takes some time to appear, the mem form obly appears when the map i complete,
meanwhile the user still sees the actual mem form.
If the user gets impatient and leaves the filter form while the map form is beeing generated this thread is still working, the map is still beeing generated.
The same if the user enters again to the filter form and press again the map button.
Is there any way to show the map mem form before the map generation is beeing made? and show a message like "wait for the map"
Is there any way to delete the map thread if the user leaves the page and the map generation isnt finished?
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to donot generate multiple threads of the same page
« Reply #1 on: November 19, 2022, 10:45:54 PM »
>> Is there any way to show the map mem form before the map generation is being made? and show a message like "wait for the map"

Is this page mode, or popup mode?

>> Is there any way to delete the map thread if the user leaves the page and the map generation isn't finished?

no.

Cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to donot generate multiple threads of the same page
« Reply #2 on: November 20, 2022, 03:29:06 AM »
Page mode
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to donot generate multiple threads of the same page
« Reply #3 on: November 20, 2022, 10:06:06 PM »
I'm thinking you should maybe break down the process into 2 parts - show the map with no data, then add the data in the background. Construct it as a button push - ie page appears, push button, data appears on the map. Then once that's done you can automate the button-push when the page opens.

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to donot generate multiple threads of the same page
« Reply #4 on: November 28, 2022, 06:09:17 AM »
And to delete the ?orphan?threads, that  wich the user fired but leave the page...
How about a Memory file, adding a record when starting the proc, saving the sessionID and threadNr which fires it, and inside the proc, in the loop reading the map pionts, fetch if there are a record with this sessionID and different theradNr, and then kill the tread?
Or notify all thrads that IM beggining the process using a sessionID and inside the proccess if I have the same SessionID then kill the process.
This could be a feature in NT14 !
BTW, hows the best way to kill the tread?
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to donot generate multiple threads of the same page
« Reply #5 on: November 28, 2022, 09:58:25 PM »
>> And to delete the ?orphan?threads, that  which the user fired but leave the page...

it's not possible to do - because you can't tell that the user has "left the page".

>> How about a Memory file, adding a record when starting the proc, saving the sessionID and threadNr which fires it, and inside the proc, in the loop reading the map points, fetch if there are a record with this sessionID and different threadNr, and then kill the tread?

Under what circumstances would the memory file record be removed though. You don't get a notification that the user left the page, so....

If you really wanted to do this you could do some complicated scheme with the progress bar - if the user left the page then the progress requests would stop, and so the memory line could "time out".

Or alternatively you could put a web socket on the page, so as long as the web socket is open the connection is there, if the web socket closes then you st something so the thread knows to end.

>> Or notify all threads that IM begining the process using a sessionID and inside the proccess if I have the same SessionID then kill the process.
>> BTW, hows the best way to kill the tread?

you don't kill a thread from outside. You set a global flag, which the thread is monitoring, and if the flag is set then it kills itself.

>> This could be a feature in NT14 !

Maybe. Sounds complicated and prone to failure, but maybe.

cheers
Bruce

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to donot generate multiple threads of the same page
« Reply #6 on: December 15, 2022, 07:39:39 AM »
I'm thinking you should maybe break down the process into 2 parts - show the map with no data, then add the data in the background. Construct it as a button push - ie page appears, push button, data appears on the map. Then once that's done you can automate the button-push when the page opens.

Hi Bruce, I did it, Ive added a button which sets a session variable and refreshs the map, then when entering the page, this session variable is false and the map filters does not add any points on the map, than I push the button using js, the buetton sets the variable to true and refresh tha map which adds the points to the Map.
Its working but I need to show the busy.gif in the meantime and I cant
Im using
   p_web.Script('$("#_busy").css(''left'',''50%'').css(''top'',''40%'').css(''display'',''flex'');')
   to show the busy when I press the button
   and p_web.Script('$("#_busy").css(''display'',''none'');') when the map is done.
but I think maybe p_web.NtMap are hiding it in any way.   
Then two questions:

1- how to solve the busy.gif thing
2- how to do it using a progress bar

Thanks
-----------
Regards
Alberto

Alberto

  • Hero Member
  • *****
  • Posts: 1873
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
Re: How to donot generate multiple threads of the same page
« Reply #7 on: December 20, 2022, 05:29:29 AM »
Hi Bruce, any ideas?
-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: How to donot generate multiple threads of the same page
« Reply #8 on: December 22, 2022, 09:11:50 PM »
Alas, no ideas Alberto.
I guess you need to break it down some more, and figure it out.

Perhaps create small examples to show the effect you are trying.

Maybe use a different Busy graphic, which you can unhide, and hide, without worrying about mine.