🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14634

Re: Threads and Timer problem

#14634
From: Stephan
Date: Tue, 05 Aug 2003 11:33
72 lines
3414 bytes
Hi
I haven't coded a timer in a thread myself, and thinking about it,
brings one thing to mind: when the timer fires, it executes an "on timer"
event.
The "on timer" event will execute when the thread isn't busy.
So, do you pause the thread so the event would fire? I don't know.

"Paul E." <paulepst69@aol.com> wrote in message
news:3f2e865d@newsgroups.borland.com...
stephan,

I really appreciate your help.
Can you please supply me with some code on how to start the timer in the
Execute method, the way you explain it.

Thank your for your help...



"Stephan" <slaska@devarinc.com> wrote in message
news:3f2e4804@newsgroups.borland.com...
> Hi
>     you have an interesting thing going on here, but I don't think it's
> doing what you want.  As you know, when you create a thread,
> it runs independently of the process that creates it. It still takes time
> and resources to execute. The good thing about it is it will allow
> the main program to react to user input, redraw the screen, etc
> while the thread is busy doing some processor intensive task.
>
> The major task to deal with in a thread is to get the results of the
> thread task back to main program. there are several ways of doing
> this, including the synchronize method, and mutexs
>
> The synchronize method takes a bit of code written for the thread
> and causes it to execute in the main thread (program).
>
> The synchronized code can only execute in the main thread when the
> main thread is not executing any other code
>
> The code you wrote starts a timer in the main thread
>
> perhaps what you meant to do was to have the timer run in the thread?
> in that case, start the timer in the Execute method, then the timer event
> should call a routine that Synchronizes the code that you want to execute
> in the main thread.
>
> Have Fun
> Stephan
>
> "Paul E." <paulepst69@aol.com> wrote in message
> news:3f2daa27@newsgroups.borland.com...
> application must process few function every 1-5 seconds,
>
> void __fastcall TIMConnection::Execute()
> {
>     while(Terminated==false)
>     {
>         Synchronize(RUNME);
>         Close();
>     }
> }
>
> void __fastcall TIMConnection::RUNME(void)
> {
>     Mytimer = new TTimer(NULL);
>     Mytimer->Interval = 5000;
>     Mytimer->Enabled = true;
>     Mytimer->OnTimer=MytimerTimer;
> }
>
>
>
Technical Details
Message-ID: <3f2f9619$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-05!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3f2daa27@newsgroups.borland.com> <3f2e4804@newsgroups.borland.com> <3f2e865d@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,ece7f64e3f770b72
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-05 04:36:32 PST
From: "Stephan" <slaska@devarinc.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f2daa27@newsgroups.borland.com> <3f2e4804@newsgroups.borland.com> <3f2e865d@newsgroups.borland.com>
Subject: Re: Threads and Timer problem
Date: Tue, 5 Aug 2003 07:33:45 -0400
Lines: 76
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 64.252.14.74
Message-ID: <3f2f9619$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1060083225 64.252.14.74 (5 Aug 2003 04:33:45 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-05!sn-xit-09!supernews.com!newshosting.com!news-xfer2.atl.newshosting.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail