내가 1000 초 간격으로 System.Windows.Forms.Timer
을 가지고 있다고 상상해보십시오.System.Windows.Forms.Timer 클래스에서 Start()를 두 번 호출하면 어떻게됩니까?
Timer.Start()
메서드를 호출하고 500ms 후에 다시 Timer.Start()
을 호출하면 어떻게됩니까? 두 번째 Start
통화는 간격을 재설정할지 여부를 결정합니다. 부작용이 있습니까?
내가 1000 초 간격으로 System.Windows.Forms.Timer
을 가지고 있다고 상상해보십시오.System.Windows.Forms.Timer 클래스에서 Start()를 두 번 호출하면 어떻게됩니까?
Timer.Start()
메서드를 호출하고 500ms 후에 다시 Timer.Start()
을 호출하면 어떻게됩니까? 두 번째 Start
통화는 간격을 재설정할지 여부를 결정합니다. 부작용이 있습니까?
Start()는 Enabled 속성을 true로 설정합니다. Enabled 속성이 이미 true로 설정된 경우 Enabled를 true로 다시 설정하고 계속 진행합니다.
마찬가지로 Stop()은 Enabled를 false로 설정합니다. 유 시작하면 아무 영향을 미치지 않습니다 두 번째 시작을 반환 입력하면 그것은 아무 영향을받지 않습니다
...
이 코드
class TimerTest
{
static int i = 0;
static void Tick(object sender, EventArgs e)
{
Console.WriteLine(i);
i++;
}
static void Main()
{
// interval = 500ms
Timer tmr = new Timer();
tmr.Interval = 500;
tmr.Elapsed += Tick;
tmr.Start();
Console.ReadLine();
tmr.Start();
Console.ReadLine();
tmr.Stop();
Console.ReadLine();
tmr.Start();
Console.ReadLine();
tmr.Dispose(); // This both stops the timer and cleans up.
}
}
를 참조하십시오.
글쎄, 시도해보고 어떻게 될지 알아보십시오. –