//버튼 클릭 시 타이머 시작
private void beforebt_Click(object sender, EventArgs e)
{
timer1.Enabled = true; // timer1_Tick 실행시 먼저 true로 설정
timer1.Tick += new EventHandler(timer1_Tick);
if (BeforeCompare)
{
BeforeSettingProc();
}
}
private void beforebt_Click(object sender, EventArgs e)
{
timer1.Enabled = true; // timer1_Tick 실행시 먼저 true로 설정
timer1.Tick += new EventHandler(timer1_Tick);
if (BeforeCompare)
{
BeforeSettingProc();
}
}
void timer1_Tick(object sender, EventArgs e)
{
timer1.Interval = 1000;
TimerSecond++;
if (t3.Minutes == TimerMin && t3.Hours == TimerHour)
{
//Sound play todo
MessageBox.Show("sound ok");
TimeReInit();// 다시 시간을 초기화 (timer1.Enabled = false로 설정)
}
else
{
if (TimerSecond == 60)
{
TimerMin++;
TimerSecond = 0;
if (TimerMin == 60)
{
TimerHour++;
TimerMin = 0;
}
}
}
}
Timer1_Tick 이벤트 함수 호출전 Enabled를 제일 먼저 True로 바꿔줘야 Tick함수가 호출된다.
이와 같은 코드는 타이머 이벤트 발생 X (버튼을 두번 누르면 발생 할 수도 ???)
잘못된 코드방식이다.
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Enabled = true;
'Project > SMI' 카테고리의 다른 글
[C#] TextBox에 입력받은 문자열이 숫자 인지 판별 (0) | 2010.12.06 |
---|---|
SMI (WindowMobile Programming) (0) | 2010.12.06 |
[C#] DateTime을 이용한 알람 설정 (0) | 2010.12.06 |
[C#] String속성 : LastIndexOf (0) | 2010.12.04 |
[C#] Window Mobile 강제로 Explorer 실행하기 (0) | 2010.12.04 |