Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Question about multithread in powerbuilder 9

Status
Not open for further replies.

BBO007

Programmer
Jun 11, 2009
18
GB
Hello All,

I would like to know if there is people that familiar with the multithreading in PB 9 ?

I would like to launch a separate thread that will retieve data from the Oracle database, and during the same time the main process continues its job.

I have understand that I need to use the functions
SharedObjectRegister, SharedObjectGet and SharedObjectUnregister but I not able to get the result of the retrieve.

Any help will be very much appreciated.
Thorben
 
Does the 'database' thread have it's own transaction object?

Matt

"Nature forges everything on the anvil of time
 
Hi Matt,

For the moment : No !

Does it need to have its transaction object ?
 
Yes, it's my understanding that it does.

Matt

"Nature forges everything on the anvil of time
 
Ok,
I have make it so that it has its own transaction object.

But I still have the issue.

I have tested my code in normal mode (without calling the function SharedObjectRegister) and this is working find.

So I still do not understand why when I use the multithread mode, I a not able to retrieve the contents of the datastore. I even don't know if the datastore is filed in or not. I don't know if the retrieve has worked.
It seems that it has not updated the nvo used as an interface.

Thorben
 
don't know too much about this (very interesting) but I suppose you have checked the values returned by:

SharedObjectRegister, SharedObjectGet and SharedObjectUnregister ???

send me some code if you like and i'll try to (learn and) help

miguel
 
for your purpose you don't need to do things by multithreading.

A)
If you use a datawindow and simply put a comment in the "retrieveRow" event:
// no code needed a simple comment does the trick...

your code will continue to execute, while retrieving data.
(thought it does decrease performence).

B) use a new transaction object for your specific datawindow that you want to retrieve without waiting and do a settransobject with that transobject for your dw: you can use the 'Async(hronous)' dbparm when you connect to thisa transaction object. If I'm right the retrieve will also allow your code to continue without waiting for the retrieve to finish and without the need of coding the retrieveRow event. Though in powerbuilder help I read that it is "necesary" to code that event, I seem to remember that it is not ... I'd try to see if that's really necessary since it slows down performence.
(it could be that pb states it to be necesary, for the reason to be able to do a dbcancel() to interrupt the retrieve, but not necesary if you don't want to cancel and simply want the execution to be asynchronous)

Sorry for my lousy forgotten english.


You can do a retrieve of your data 'asynchronously':
------------------------------- (copied the text from pb help):
-----
Description

Allows you to perform asynchronous operations on your database in PowerBuilder. If you have coded a RetrieveRow event for a DataWindow object or report, you can cancel the current database retrieval operation or start another (non-database) operation that does not use the same database connection before the current operation completes. You can also switch to another Windows process while the retrieval takes place.
By default, PowerBuilder operates synchronously.

Applies to

DIR Sybase DirectConnect
IN9 Informix
JDB JDBC
ODBC (if driver and back-end DBMS support this feature)
O84 Oracle 8.x and Oracle8i (8.1.5 and higher database connections only)

O90 Oracle9i

SYC Sybase Adaptive Server Enterprise

Syntax

Async = value

Parameter Description
value A value specifying synchronous or asynchronous operation. Values are:· 0 (Default) Synchronous operation· 1 Asynchronous operation
Default

Async = 0

Usage

Enabling asynchronous operation in PowerBuilder is useful when you are executing a complex SQL statement that takes several minutes to return results. If the Async parameter is set to 1, you can do either of the following while the SQL statement is executing:

· Work in another window
· Cancel the statement before it retrieves the first row of data

When to set Async If you are communicating with the database in code, you can reset the Async value at any time before or after the Transaction object has connected to the database.
How data is retrieved When you retrieve data in a DataWindow object or report, the following steps occur in order:


1 The database server compiles and executes the SQL statement.
2 PowerBuilder retrieves (fetches) the first row of data.
3 PowerBuilder retrieves each subsequent row of data.

What happens before the first row is retrieved While the server is compiling and executing the SQL statement and before PowerBuilder retrieves the first row of data, you must have done both of the following to enable asynchronous operation (allowing you to cancel the current operation before it retrieves the first row of data):

· Coded a RetrieveRow event for the DataWindow object or report (the code can contain only a comment)
· Set the Async parameter to 1

What happens after the first row is retrieved After the first row of data is retrieved and between subsequent row fetches, you must have done only the following to enable asynchronous operation:

· Coded a RetrieveRow event for the DataWindow object or report

After the first row is retrieved, PowerBuilder operates asynchronously without your having to set the Async parameter to 1, so you can cancel the current operation anytime after it retrieves the first row of data. Therefore, the Async parameter has no effect in PowerBuilder after the first row of data is retrieved.

regards,
Miguel L.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top