I am creating a game and I want the player to only be allowed on one form for approx. 15 seconds or depending on the question on the form, it may be a sooner time such as 7 seconds but for the timer it is only in milliseconds, will i have to make it 7000 for the interval or if there is a more simple way could someone lead me onto the correct path? im not asking for code just for a direction to go with this, thanks :) if you need more information because i did not explain it very well just ask and ill do my best.

有帮助吗?

解决方案

It's exactly as you say. If you want to do something after 7 seconds then you set the Interval of a Timer to 7000. Interval is an Integer so it can support values over 24 days.

Actually, another option for one-off actions nowadays is the Task.Delay method. I'd go with the Timer though, because you will need to act on the UI thread and the Task will act on a secondary thread.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top