I am using the following code to display a message box when the charging level is reached
private void timer1_Tick(object sender, EventArgs e)
{
battery = Convert.ToInt32(power.BatteryLifePercent * 100);
while (battery == 100)
{
MessageBox.Show("charging full disconnect the charger");
}
}
this code is working . but it is showing messagebox more than once. I just want to show it only once.
Thank you
Without more information it is hard to determine the actual problem. However, you can probably quickly fix the issue by using a variable to track whether you have displayed the message yet.
Although, ideally, this code simply wouldn't be called unless it is time to show the message. I would need to see the larger picture to figure that out though.