1. Shawn Davis
  2. PowerServer
  3. Thursday, 4 May 2023 16:14 PM UTC

Hello All,

Is multithreading supported with PB 2022/PS 2022? If so, does anyone have examples to share? We've been playing with it but it seems to produce random freeze ups. We're using the sleep function in the user object to time the activity of it, should that work as expected?

Thx,

Shawn

Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 4 May 2023 16:30 PM UTC
  2. PowerServer
  3. # 1

Hi Shawn;

   FYI: http://chrispollach.blogspot.com/2023/04/multi-thread.html

  The PB 2022 example App includes 32 & 64 bit EXE deployments, P-Code/M-Code support, PowerClient & PowerServer deployment projects. HTH.  ;-)

Regards ... Chris 

Comment
  1. Miguel Leeuwe
  2. Saturday, 1 July 2023 05:57 AM UTC
Right, also, no messageboxes or any file dialogs if I'm not mistaken. You can't do anything "visual" in a shared object.
  1. Helpful
  1. John Fauss
  2. Saturday, 1 July 2023 13:25 PM UTC
Correct, Miguel. Any action the spawned thread performs that requires ANY visual (GUI) interaction will cause the thread to “freeze”, because the Windows O/S does not support the underlying infrastructure that GUI requires.

If you execute the non-visual object that performs the multi-threaded task as an object in the GUI thread (i.e. don’t create the NVO using the SharedObjectXxxxxx PowerScript functions) and it does not freeze (it runs and completes without issues), then it is likely that these is some visual work being performed. In Shawn’s case, Outlook is a visual application that was not designed to be run without GUI interaction, so it does not surprise me that he is experiencing this issue. He may need to come up with an alternative solution.
  1. Helpful
  1. Miguel Leeuwe
  2. Saturday, 1 July 2023 18:15 PM UTC
Hi John,

Using OLE, you CAN do Outlook stuff without having anything visual. I THINK it would be possible also in a shared object, but haven't tried myself.
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Thursday, 4 May 2023 17:43 PM UTC
  2. PowerServer
  3. # 2

Hi, Shawn -

What are considering using multi-threading for? Inquiring minds would like to know...

Here's a link to a PB Tech Article about the in's and out's regarding multi-threading in PB:

    https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/339-free-my-gui-multi-threading-in-powerbuilder

Here's a link to a multi-threaded data retrieval example PB application that accompanies the article:

    https://community.appeon.com/index.php/codeexchange/powerbuilder/307-a-multi-threaded-data-retrieval-example

I've not tested the example app with PowerServer.

Best regards, John

Comment
  1. Shawn Davis
  2. Thursday, 4 May 2023 17:48 PM UTC
One thread is for an object that uploads files. If there are more than a few we don't want to stop the main app while that happens.



The other is to connect to Outlook to scan the inbox for certain emails and upload if found.
  1. Helpful
  1. mike S
  2. Friday, 30 June 2023 19:58 PM UTC
we use multi-threading to check for results of a web api call that runs a process. It does this via polling of a table and it is in a different thread. One of the processes can create a results file - which is automatically downloaded in this thread.



no problems with anything freezing up.



PS 2022 build 1900
  1. Helpful 1
There are no comments made yet.
Shawn Davis Accepted Answer Pending Moderation
  1. Thursday, 13 July 2023 16:53 PM UTC
  2. PowerServer
  3. # 3

I want resurrect this one. We've wrestled with multi-threading and it just keeps freezing the whole app. We've search the execution thread for any visual component and can't find one. And, as bets we can tell we're doing everything correctly. (We open a separate window and have an NVO that we put on another thread to process OLE and file drag and drop).

So, I had the idea that when our app opens it opens the window in question as a separate app so it has it's own thread right from the start. However we need to pass a parameter to the window and looks like PS doesn't support command line parameters. 

Any advice on opening a separate window as it's own app using PS? Or just any advice at all?  Thanks!

Comment
  1. Miguel Leeuwe
  2. Thursday, 13 July 2023 17:59 PM UTC
Not an expert at all, but maybe in PS the way to go is NOT using a Shared Object. I think there's plenty of stuff in .Net to do things asynchroneously or even in parallel ?
  1. Helpful
  1. Miguel Leeuwe
  2. Thursday, 13 July 2023 18:02 PM UTC
As for opening a separate window as its own app, that wouldn't work in PS .Net. It would have to be on the PB side, so either some MDI window or a complete new separate application. I think it would be possible to communicate between them using Sockets, but haven't got a clue about that either.
  1. Helpful
  1. mike S
  2. Thursday, 13 July 2023 18:48 PM UTC
fwiw, i am using multi-threading in PS 2022



you can also send a commandline to a ps app. I do that to open up a document.
  1. Helpful
There are no comments made yet.
Chris Pollach @Appeon Accepted Answer Pending Moderation
  1. Thursday, 13 July 2023 18:57 PM UTC
  2. PowerServer
  3. # 4

Hi Shawn;

  Engineering just found a Multi-threading bug in PB 2022 as in ticket # 10482. There is now a hot fix for that issue and the developer who opened the the ticket now reports that there issue (which only started in 2022) is now working correctly. Your issue might (my guess) be related. This fix will be in 2022 R2 GA.

Regards ... Chris

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.