Execute specified function every X seconds

后端 未结 4 1857
小鲜肉
小鲜肉 2020-11-27 15:02

I have a Windows Forms application written in C#. The following function checks whenever printer is online or not:

public void isonline()
{
    PrinterSettin         


        
4条回答
  •  时光说笑
    2020-11-27 15:20

    The most beginner-friendly solution is:

    Drag a Timer from the Toolbox, give it a Name, set your desired Interval, and set "Enabled" to True. Then double-click the Timer and Visual Studio (or whatever you are using) will write the following code for you:

    private void wait_Tick(object sender, EventArgs e)
    {
        refreshText(); // Add the method you want to call here.
    }
    

    No need to worry about pasting it into the wrong code block or something like that.

提交回复
热议问题