最佳答案
I have a Windows Forms application written in C#. The following function checks whenever printer is online or not:
public void isonline()
{
PrinterSettings settings = new PrinterSettings();
if (CheckPrinter(settings.PrinterName) == "offline")
{
pictureBox1.Image = pictureBox1.ErrorImage;
}
}
and updates the image if the printer is offline. Now, how can I execute this function isonline()
every 2 seconds so when I unplug the printer, the image displayed on the form (pictureBox1
) turns into another one without relaunching the application or doing a manual check? (eg. by pressing "Refresh" button which runs the isonline()
function)