I am looking for a way to show a notification when a record has been inserted.
This is what i have:
public static void Method()
{
int count = int.MinValue;
int prev_count = int.MinValue;
//Get count from MySQL table
using (var conn = new MySqlConnection(ConnectionString.ConnString))
{
conn.Open();
var cmd = new MySqlCommand("select count(*) from table;", conn);
count = Convert.ToInt32(cmd.ExecuteScalar());
conn.Close();
}
if (count != prev_count)
{
PopupNotifier popup = new PopupNotifier();
popup.TitleText = "Record";
popup.ContentText = "New record has been added.";
popup.Popup();
prev_count = count;
}
}
I have tried this: https://stackoverflow.com/a/62193334/13678741
But that simply runs the notification every 5 seconds.
When the form loads - I need to check the number of records and constantly compare it to previous number, if changed then notify user.
What is an ideal method to notify user if a record has been added to the table? Is mine doable?