wip
This commit is contained in:
parent
0010a32248
commit
ddb6abc14e
14 changed files with 754 additions and 718 deletions
|
|
@ -1,21 +1,23 @@
|
|||
using Npgsql;
|
||||
|
||||
class TestPostgresLISTENNOTIFY
|
||||
namespace PlanTempus.X.TDD.CodeSnippets;
|
||||
|
||||
internal class TestPostgresLISTENNOTIFY
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
var connectionString = "Host=192.168.1.57;Database=ptdb01;Username=postgres;Password=3911";
|
||||
|
||||
try
|
||||
{
|
||||
await using NpgsqlConnection conn = new NpgsqlConnection(connectionString);
|
||||
await using var conn = new NpgsqlConnection(connectionString);
|
||||
await conn.OpenAsync();
|
||||
|
||||
Console.WriteLine("Forbundet til databasen. Lytter efter notifikationer...");
|
||||
|
||||
conn.Notification += (o, e) =>
|
||||
{
|
||||
Console.WriteLine($"Notifikation modtaget:");
|
||||
Console.WriteLine("Notifikation modtaget:");
|
||||
Console.WriteLine($" PID: {e.PID}");
|
||||
Console.WriteLine($" Kanal: {e.Channel}");
|
||||
Console.WriteLine($" Payload: {e.Payload}");
|
||||
|
|
@ -29,10 +31,7 @@ class TestPostgresLISTENNOTIFY
|
|||
|
||||
Console.WriteLine("Tryk på en tast for at stoppe...");
|
||||
|
||||
while (!Console.KeyAvailable)
|
||||
{
|
||||
await conn.WaitAsync();
|
||||
}
|
||||
while (!Console.KeyAvailable) await conn.WaitAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue