1. John Brown
  2. PowerBuilder
  3. Thursday, 21 July 2022 20:27 PM UTC

All -

I'm new to the application I'm working on.  It's OLD, but was migrated to Appeon 2017 a few years ago.

They have a window with an "Apply" button and a "Cancel" button.

Correct me if I'm wrong - but if they click Apply and then click Cancel, the cancel process won't start until after the Apply process has completed, correct?

And if that is how it processes, is there a way to write it in PB that will function like a normal Cancel button and stop the processing?

 

Thanks,

John

John Fauss Accepted Answer Pending Moderation
  1. Thursday, 21 July 2022 22:07 PM UTC
  2. PowerBuilder
  3. # 1

First part: You are correct. Nearly all PB apps are single-threaded. This "main" thread not only executes the code in the app, but also has to handle all GUI-related work. Thus, when code from a command button's Clicked event is executing, no GUI events can be processed...Windows queues them in the active window's message queue, but the app is "preoccupied" and doesn't get a chance to check for GUI (or any other type of) messages.

Second part: It depends. Is the Apply button's code doing computational work, file I/O (copying/reading/writing), network tasks (FTP, for example), or database activity (long-running data retrieval, for instance)?

If computational work, you may be able to periodically call the PowerScript Yield() function with the loop/process. This tells PB to go check the active window's message queue and if any are present, process them. This has the potential to be dangerous; For example, if the user clicks the "X" button to close the window, or does something to start another long-running process.

Multi-threading IS possible in PB, but only for non-GUI-related tasks like computations, database retrievals, file I/O, etc. A PB app can have only one GUI execution thread. Multi-tasking is a relatively advanced topic and the standard Help materials really do not cover the subject well.

If you're interested, I've recently published two tech articles: One concerning non-responsive applications and the other on multi-tasking in PB.

First article is here:

   https://community.appeon.com/index.php/articles-blogs/tutorials-articles/2-powerbuilder/325-why-unresponsive-application-windows-are-ghosted-by-the-windows-o-s

The other is here:

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

Each has an accompanying example application in CodeXchange that illustrates the material being discussed.

HTH, John

 

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.