Created
July 24, 2017 18:18
-
-
Save redbaty/d9a19a76ad70bcc37d92005dd1a6e2b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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