Execute PgScript NonBlocking Mode

Execute PgScript NonBlocking Mode

Postby chris901 » Sun 07 Aug 2016 15:46

Hello,

in the DataTable component there is a NonBlocking Property so the GUI doesn't freeze on long running operations.

Scripts tend do execute long running operations as well. How can i run execute a PgScript and not block the GUI.

Is it possible to introduce the NonBlocking property to the PgScript component?

Thanks.
chris901
 
Posts: 64
Joined: Wed 20 Jul 2016 04:21

Re: Execute PgScript NonBlocking Mode

Postby Pinturiccio » Tue 09 Aug 2016 15:58

PgSqlDataTable can be executed asynchronously. PgSqlScript does not support asynchronous execution, that’s why a property similar to the NonBlocking property of the PgSqlDataTable class cannot be implemented for PgSqlScript.

If you want PgSqlScript execution not to freeze your GUI, you should execute PgSqlScript in a separate thread. Please note, that dotConnect for PostgreSQL is not thread safe, so you should use a separate connection for each thread or synchronize the threads yourself.
Pinturiccio
Devart Team
 
Posts: 2020
Joined: Wed 02 Nov 2011 09:44

Re: Execute PgScript NonBlocking Mode

Postby chris901 » Tue 09 Aug 2016 16:14

How about executing the Script operations in a Task?

Task.Factory.StartNew(MethodThatUsesScriptOperations);

In my simple test case it works fine. Anything i should be aware of?
chris901
 
Posts: 64
Joined: Wed 20 Jul 2016 04:21

Re: Execute PgScript NonBlocking Mode

Postby Pinturiccio » Thu 11 Aug 2016 14:20

Yes, it should work; however, you have to care about PgSqlConnection synchronization yourself, because dotConnect for PostgreSQL is not thread safe.
Pinturiccio
Devart Team
 
Posts: 2020
Joined: Wed 02 Nov 2011 09:44


Return to dotConnect for PostgreSQL