Does the System.Windows.Forms.Timer run on a different thread than the UI?

后端 未结 5 1544
眼角桃花
眼角桃花 2020-12-01 14:24

I have a main thread that creates a form object which creates and sets a timer to run a function named updateStatus() every minute. But updateStatus() is also called by the

5条回答
  •  攒了一身酷
    2020-12-01 14:35

    No.

    The whole point of a Windows.Forms Timer is that it runs on the GUI Thread.

    Windows (WinForms) runs something called the MessagePump (see Application.Run()) and this is what makes the Timer possible.

    All your code runs as part of an Eventhandler somehow, and a Timer tick will never 'interrupt' any other event handler.

提交回复
热议问题