C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[22506] [질문] Hellix의 ThreadTimer..
이상민 [smleelms] 1057 읽음    2002-11-08 11:33
Hellix의 ThreadTimer 콤포넌트를 사용하고 있습니다..
이넘을 동적으로 할당해 사용하고 있는데요, 동적으로 할당한뒤 interval을 주고 enable을 시키면 다른 프로세서가 interval 동안 죽어버리는군요.

즉 10초 interval을 주고 동작시킨뒤, 다른 버튼을 누른다던지 하면 10초-지난시간 뒤에 (즉 최대 10초동안은 버튼이 동작을 하지 않다가) 동작을 합니다. 이벤트를 바로 받아주지 않더군요.

그래서 소스를 봤더니..


void __fastcall TTimerThread::Execute()
{
   Priority = OwnerTimer->ThreadPriority;

   WORD LastStart;   // Time at which the last synchronisation started
   WORD LastDuration = 0;   // Number of milliseconds since the last execution

   while (!Terminated)
   {
    if (LastDuration < OwnerTimer->Interval)
        // The last execution took less than the timer's interval, therefore we
        // wait the difference between the two of them

        SleepEx(OwnerTimer->Interval - LastDuration, false);
      else
        // The last execution took longer than the timer's interval, so there
        // is no time to waste, if enough to process some messages to allow the
         // application to do a few things

        Application->ProcessMessages();

      if (!Terminated)   // The thread was not woken
      {
        LastStart = GetTickCount();   // Remember the time at which the
                                       // synchonisation started

        Synchronize(OwnerTimer->Timer);

        LastDuration = GetTickCount() - LastStart;   // Calculate the duration
                                                      // of the synchronisation
      }
   }
}

이렇게 구현되어 있는데요...
아무래도 SleepEx(OwnerTimer->Interval - LastDuration, false)
이부분에서 잡아먹고 있는것 같은데..

이부분에서 thread 이벤트가 아닌, 일반 이벤트(?)를 받아들이게 할수 없을까요 ?
제가 구성한 이 부분은 다음과 같이 타이머를 false시키고 삭제시키는 동작입니다.

void __fastcall TMainForm::btnStartStop(TObject *Sender)
{
    if(ThdTimer != NULL){
        ThdTimer->Enabled = false;
        delete ThdTimer;
        ThdTimer = NULL;
    }
}

이 버튼이 타이머 interval 시간이 지난뒤 OnTimer로 할당된 함수를 부를 시점이 되어야 동작이 된다는 겁니다.

이 버튼이 바로 동작이 되게 할 수는 없을까요 ?

+ -

관련 글 리스트
22506 [질문] Hellix의 ThreadTimer.. 이상민 1057 2002/11/08
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.