
As you will discover, the asynchronous mechanism can be used in many powerful ways. At this point, however, let's look at a very simple example just to see how it works.
int
main() {
RWDBDatabase aDb = RWDBManager::database(
"SYBASE_CT",
"sybase_server",
"sybase_user",
"password",
"DEMO_DB"
);
RWDBConnection asyncConn =
aDb.connection(RWDBConnection::Asynchronous); //1
RWDBResult result =
aSyncConn.executeSql("create table X(y int)"); //2
while (! result.isReady()){ //3
// Do something useful here
cout << "Waiting for completion " << endl; //4
}
assert(result.isValid()); //5
return 0;
}
On //1 an asynchronous connection is obtained from the database object. On //2 a create table query runs using the ::executeSql method. This method has been invoked asynchronously by supplying the asynchronous connection obtained in //1. Then //3 checks whether the returned RWDBResult object is ready or not. If the RWDBResult object is not ready, it goes into the loop and does some work in //4. In this example, the work done in //4 gets repeated until the RWDBResult object gets to a ready status. //5 checks whether the call has been executed correctly or not.
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.