您好我需要一点帮助我将通知消息发送到我的c#app,然后我得到它出现在控制台上的消息,但如果我尝试在应用程序窗口上设置标签内容,那么这就是代码:
using (var conn = new NpgsqlConnection("Server=xxxxx"))
{
conn.Notification += OnNotification;
conn.Open();
using (var command = new NpgsqlCommand("listen mymessage;", conn))
{
command.ExecuteNonQuery();
}
mymessage = Console.ReadLine();
};
Console.WriteLine(mymessage);
}
public void OnNotification(object sender, NpgsqlNotificationEventArgs e)
{
Console.WriteLine(e.AdditionalInformation);
label1.Content = e.AdditionalInformation;
}
console writeline有效但label1.content不会改变