Page 1 of 1
Execute PgScript NonBlocking Mode
Posted: Sun 07 Aug 2016 15:46
by chris901
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.
Re: Execute PgScript NonBlocking Mode
Posted: Tue 09 Aug 2016 15:58
by Pinturiccio
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.
Re: Execute PgScript NonBlocking Mode
Posted: Tue 09 Aug 2016 16:14
by chris901
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?
Re: Execute PgScript NonBlocking Mode
Posted: Thu 11 Aug 2016 14:20
by Pinturiccio
Yes, it should work; however, you have to care about PgSqlConnection synchronization yourself, because dotConnect for PostgreSQL is not thread safe.