Public Sub Async_Exec(ByVal pgConnection As PgSqlConnection)
Dim pgCommand As New PgSqlCommand("SELECT * FROM Test.Dept", pgConnection)
Console.WriteLine("Starting asynchronous retrieval of data...")
pgConnection.Open()
Dim cres As IAsyncResult = pgCommand.BeginExecuteReader(Nothing, Nothing, CommandBehavior.Default)
If cres.IsCompleted Then
Console.WriteLine("Completed.")
Else
Console.WriteLine("Have to wait for operation to complete...")
End If
Dim pgReader As PgSqlDataReader = pgCommand.EndExecuteReader(cres)
Try
While pgReader.Read()
Console.WriteLine(String.Concat(pgReader.GetInt32(0), " ", pgReader.GetString(1), " ", pgReader.GetString(2)))
End While
Finally
pgReader.Close()
pgConnection.Close()
End Try
End Sub