[카즈] MYPI

[카즈]
접속 : 3665   Lv. 54

Category

Profile

Counter

  • 오늘 : 15 명
  • 전체 : 159915 명
  • Mypi Ver. 0.3.1 β
[학업] C# 어떤걸로 해야 하는지.. 멘붕이네요 (9) 2014/03/24 PM 10:37

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(); 부분이 에러가 나네요... 간단한걸텐데 멘붕입니다 ㅠ

신고

 

이리와야    친구신청

위 코드로 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 계산해서 넣으면 되나요?

GreatJS    친구신청

음.. DispatcherTimer를 사용하시려면 windowsbase.dll 을 참조 추가해야됩니다~

[카즈]    친구신청

오 감사합니다! 그러나 아직 오류가 있네요..

non-oan    친구신청

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();
}

이렇게 하면 되지 않을까요?
X