Today i wrote the following code that works with PostgreSQL C# library named Npgsql:
using System;
using System.Collections.Generic;
using System.Linq;
using
Unless your client library supports checking the network socket for buffered data, the only way to receive notifications is to trigger some other activity on the socket.
Many applications periodically send an empty query string (""
) to do this.
If the client library supports it and you are not using SSL, it might be possible to periodically call some kind of checkForNotifications() function on the connection. This is possible in PgJDBC, but I don't know nPgSQL, so I can only advise you to check out the documentation for that.