Asynchronous BeginFill() does not return immediately
Posted: Wed 09 Jan 2013 16:01
A asynchronous call to PgSqlDataTable.BeginFill() does not return immediately, as expected, thus beeing rather useless, as it is blocking the working thread of our Application until the database has completed the given command.
### Example, c# ####
private void Test()
{
PgSqlDataTable myDataTable = new PgSqlDataTable();
myDataTable.Connection = EdGlobals.Connection;
myDataTable.SelectCommand = EdGlobals.Connection.CreateCommand();
myDataTable.SelectCommand.CommandText = "SELECT pg_sleep(20)";
myDataTable.NonBlocking = true;
IAsyncResult aRes = myDataTable.BeginFill(null, null);
//Here, the CURRENT THREAD hangs for 20 seconds, because
//the "BeginFill()"-Method doesn't return immediately, as expected
//Instead of the command "SELECT pg_sleep(20)" you can also try
//"SELECT * from my_very_long_executing_pgsql_function()"
//with a pgsql-Function of your own that does a lot of work before returning
/*Have a look at:
*
http://www.postgresql.org/docs/9.2/stat ... async.html
Following the postgresql-documentation, the asynchronous functions should return immediately
*/
MessageBox.Show("Returned from BeginFill()");
}
### Example, c# ####
private void Test()
{
PgSqlDataTable myDataTable = new PgSqlDataTable();
myDataTable.Connection = EdGlobals.Connection;
myDataTable.SelectCommand = EdGlobals.Connection.CreateCommand();
myDataTable.SelectCommand.CommandText = "SELECT pg_sleep(20)";
myDataTable.NonBlocking = true;
IAsyncResult aRes = myDataTable.BeginFill(null, null);
//Here, the CURRENT THREAD hangs for 20 seconds, because
//the "BeginFill()"-Method doesn't return immediately, as expected
//Instead of the command "SELECT pg_sleep(20)" you can also try
//"SELECT * from my_very_long_executing_pgsql_function()"
//with a pgsql-Function of your own that does a lot of work before returning
/*Have a look at:
*
http://www.postgresql.org/docs/9.2/stat ... async.html
Following the postgresql-documentation, the asynchronous functions should return immediately
*/
MessageBox.Show("Returned from BeginFill()");
}