Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. private void PostgresNotification(object sender, NpgsqlNotificationEventArgs e)
  2. {
  3. Console.WriteLine("HELLO");
  4. Console.WriteLine("HELLO");
  5. Console.WriteLine("HELLO");
  6. Console.WriteLine("HELLO");
  7. Console.WriteLine("HELLO");
  8. Console.WriteLine("HELLO");
  9. Console.WriteLine("HELLO");
  10. Console.WriteLine("HELLO");
  11. Console.WriteLine("HELLO");
  12. Console.WriteLine("HELLO");
  13. Console.WriteLine("HELLO");
  14. Console.WriteLine("HELLO");
  15. Console.WriteLine("HELLO");
  16. Console.WriteLine("HELLO");
  17. Console.WriteLine("HELLO");
  18. }
  19.  
  20. private static NpgsqlConnection _notificationConnection;
  21.  
  22. private void StartListening()
  23. {
  24. _notificationConnection =
  25. new NpgsqlConnection(@"Host=35.188.31.108;Database=maniakids;Username=postgres;Password=88134165");
  26. _notificationConnection.Open();
  27.  
  28. var sql = "listen mynotification";
  29.  
  30. using (var command = new NpgsqlCommand(sql, _notificationConnection))
  31. {
  32. command.ExecuteNonQuery();
  33. }
  34.  
  35. _notificationConnection.Notification +=
  36. PostgresNotification;
  37.  
  38. Task.Factory.StartNew(() =>
  39. {
  40. while (true)
  41. _notificationConnection.Wait();
  42. });
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement