A Multi-Threaded Data Retrieval Example

1 year 11 months ago #400 by John Fauss
John Fauss created the code: A Multi-Threaded Data Retrieval Example
This is an example of a PowerBuilder application that can retrieve data in a separate execution thread by using a PowerBuilder shared object. It was created to accompany a PowerBuilder article on this topic in the Tech Articles section of the Articles & Blogs area of the Appeon Community web site. The application was developed using PB 2017, but it has been successfully migrated and tested in PB 2019 and PB 2021.

A primary benefit of using a shared object to perform data retrieval is it allows the application’s visual interface to remain responsive while the retrieval is being performed, avoiding Windows considering the app as "Not Responding" while the app waits for the retrieval request to complete.

If you have any DataWindow data objects you would like to test in a multi-threaded environment, the example application should be able to help you accomplish this with very little coding. If you do not have any DataWindows of your own you wish to test, the application contains five sample DataWindows where the application simulates data retrieval delays of five to sixty seconds to allow you to verify that the GUI remains responsive during data retrieval. These simulated retrievals are performed without a database connection.

You may import and test your own DataWindows, of course. In order to properly interface with any DataWindows you import, you’ll need to specify the Transaction object properties to be used, retrieval argument values (if any are needed), and DataStore Retrieve function calls (you need to code these only when retrieval argument values are used). Each DataWindow you import into this application can have its own unique Transaction object requirements. All of the customization needed to support data retrieval of imported DataWindows is accomplished in a single, well-documented non-visual object.

When running the application, you may open multiple data retrieval windows from the main application window. In each retrieval window, you may select the DataWindow data object to be retrieved, whether or not multi-threaded data retrieval is to be used, and you may also optionally request the use of Asynchronous Data Operations, or “Async”, provided the database connection you are using supports and implements this feature (not all database provider interfaces do). With Async in use, you can cancel an in-progress data retrieval request.

A “retrieval log” is displayed in each retrieval window so that you can monitor the progress of each retrieval request as it happens, when multi-threading is used. Each retrieval window can be re-positioned and resized during a multi-threaded data retrieval, and one of several included animated GIFs display in the retrieval window while multi-threaded data retrieval is in progress.

A Word document that combines a tutorial on multi-threading in PowerBuilder with an explanation of the internal workings of the multi-threaded data retrieval example application is included in the download package.

This message has an attachment file.
Please log in or register to see it.

Please Log in or Create an account to join the conversation.

Moderators: Appeon Administrator