 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
gary Guest
|
Posted: Tue Apr 26, 2005 12:24 pm Post subject: getting a component to call a function without using a TTime |
|
|
If I want my component to perform a task, say, checking if there is data in
the inbuffer, on a regular basis, how would I do this without resorting to a
TTimer. In other words, is there a more elegant way of doing things.
Any ideas will be much appreciated.
|
|
| Back to top |
|
 |
JD Guest
|
Posted: Tue Apr 26, 2005 12:32 pm Post subject: Re: getting a component to call a function without using a T |
|
|
"gary" <user (AT) home (DOT) com> wrote:
| Quote: |
how would I do this without resorting to a TTimer.
|
Use a thread.
~ JD
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Tue Apr 26, 2005 5:09 pm Post subject: Re: getting a component to call a function without using a T |
|
|
"gary" <user (AT) home (DOT) com> wrote
| Quote: | If I want my component to perform a task, say, checking if there
is data in the inbuffer, on a regular basis, how would I do this
without resorting to a TTimer. In other words, is there a more
elegant way of doing things.
|
You don't need to use TTimer if you want a timer. You can call the Win32
API SetTimer() function directly, assuming your component has its own HWND
to receive the WM_TIMER message with. Alternatively, there is
timeSetEvent(), which is a threaded multimedia timer.
Gambit
|
|
| Back to top |
|
 |
Rob Guest
|
Posted: Wed Apr 27, 2005 12:17 pm Post subject: Re: getting a component to call a function without using a T |
|
|
gary wrote:
| Quote: | If I want my component to perform a task, say, checking if there is
data in the inbuffer, on a regular basis, how would I do this without
resorting to a TTimer. In other words, is there a more elegant way of
doing things.
|
Most obvious way is to create a worker thread that does the task, calls
Sleep() for some specified number of milliseconds. If the task
involves writing data that the component needs, it is necessary to
synchronise access to that data. It is usually necessary to have some
polite way of telling the thread to terminate.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|