Search code examples
.netpostgresqlnpgsql

PostgreSQL DB with asynchronous npg connection


I have an implementation of an asynchorous notification.

Looking like this:

using (NpgsqlCommand npgsqlCommand = new NpgsqlCommand(ListeningCommand, _npgsqlConnection))
{
     npgsqlCommand.ExecuteNonQuery();
}

_npgsqlConnection.Notification += PostgresNotification;

NPG 2.x version. I had to set "SyncNotification=true;" in the connect string. Everything worked perfect.

With NPG 3.2.5 the connect string does not accept "SyncNotification=true;" and the asynchronous behavior does not work anymore.

Any advice how to do this in 3.2.5? Thanks.


Solution

  • The API for notifications has changed from 2.x to 3.2, please read the documentation.