Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save redbaty/d9a19a76ad70bcc37d92005dd1a6e2b5 to your computer and use it in GitHub Desktop.
Save redbaty/d9a19a76ad70bcc37d92005dd1a6e2b5 to your computer and use it in GitHub Desktop.
private void PostgresNotification(object sender, NpgsqlNotificationEventArgs e)
{
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
Console.WriteLine("HELLO");
}
private static NpgsqlConnection _notificationConnection;
private void StartListening()
{
_notificationConnection =
new NpgsqlConnection(@"Host=35.188.31.108;Database=maniakids;Username=postgres;Password=88134165");
_notificationConnection.Open();
var sql = "listen mynotification";
using (var command = new NpgsqlCommand(sql, _notificationConnection))
{
command.ExecuteNonQuery();
}
_notificationConnection.Notification +=
PostgresNotification;
Task.Factory.StartNew(() =>
{
while (true)
_notificationConnection.Wait();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment