• [학업] C# 어떤걸로 해야 하는지.. 멘붕이네요2014.03.24 PM 10:37

게시물 주소 FONT글자 작게하기 글자 키우기


private void timer1_Tick(object sender, EventArgs e)
{
System.Windows.Forms.Timer timer;

timer = new System.Windows.Forms.Timer();

System.TimeSpan Interval = new System.TimeSpan(3, 0, 0);
timer.Tick += new System.EventHandler(this.VCUpdate_Click);
timer.Tick += new System.EventHandler(this.ALyacUpdate_Click);
}

위 코드로 하면 오류는 없으나 3시간 주기로 발동하지 않을거같고..

--------------------------------------------------------------------------------

private void timer1_Tick(object sender, EventArgs e)
{
System.Windows.Threading.DispatcherTimer timer;

DispatcherTimer timer = new DispatcherTimer();
timer.Interval = new TimeSpan(0, 0, 5); // 타이머 주기를 설정 시 : 분 : 초
timer.Tick += new EventHandler(this.VCUpdate_Click);
timer.Tick += new EventHandler(this.ALyacUpdate_Click);// 주기가 만료되면 호출되는 함수 : timer_Tick
timer.Start();


}

위 코드는 닷넷프레임워크4 인데도 System.Windows.Threading.DispatcherTimer timer; 부분의 Threading 부분과
DispatcherTimer timer = new DispatcherTimer(); 부분이 에러가 나네요... 간단한걸텐데 멘붕입니다 ㅠ
댓글 : 9 개
위 코드로 System.TimeSpan Interval = new System.TimeSpan(3, 0, 0); 을
System.TimeSpan Interval = new System.TimeSpan(0, 180, 0); 으로 하면 안되나요??
가능한데... 인터벌이 제대로 안될거같아서 그렇습니다.
원래 timer.Interval 이어서요..
아래코드는 timer변수이름이 같은데요?
네 확인하고 삭제했습니다
그리고 위에 꺼 timer.interval에 값을 넣으시면 되는데 굳이 timespan변수를 쓰신이유가..
3시간 텀을 넣고 싶은데.. 그냥 초*1000 계산해서 넣으면 되나요?
음.. DispatcherTimer를 사용하시려면 windowsbase.dll 을 참조 추가해야됩니다~
오 감사합니다! 그러나 아직 오류가 있네요..
private void timer1_Tick(object sender, EventArgs e)
{
System.Windows.Forms.Timer timer;

timer = new System.Windows.Forms.Timer();

timer.Interval = 3 * 60 * 60 * 1000;
timer.Tick += new System.EventHandler(this.VCUpdate_Click);
timer.Tick += new System.EventHandler(this.ALyacUpdate_Click);
timer.Start();
}

이렇게 하면 되지 않을까요?
친구글 비밀글 댓글 쓰기