🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

TTimers and Critical Sections...

#11483
From: Mike Collins
Date: Thu, 05 Feb 2004 23:46
31 lines
2235 bytes
Hi all, just a quick design question.

What is the situation if I enter a Critical Section within the OnTimer event
of TTimer?  I have a TTimer that routinly polls some hardware looking for
data being sent.  When it gets the data it has to decrypt it (which
obviously has some overheads) and then propergates a structure with the
data.  As it stands, this all happens under the OnTimer event.  There is
also the main thread of the application which, in responce to certain
actions, has to check this tructure to see if it has become propergated.
The structure is faily complex - sort of :-)

Obviously there are a few, non disirable possibility that could occure
here -

1) The TTimer thread could be in the midst of decoding and propergating the
structure when the main thread stries to access it.

2) The TTimer thread could be tired up decoding and thus fire a second time
or third etc.

-therefore I figured that the safes way to deal with this is to use a
critical section and enter it when the OnTimer event fires, and leave it at
the end of the event, do the same for the main thread when it need to access
the structure.  However I don't really understand what will happen with the
timer if the event fires a second or third time.

Any help would be excellant,

Thanks in advance,

Mike C
Technical Details
Message-ID: <4022d173$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,e86366b203b792f7,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-05 15:40:36 PST
Reply-To: "Mike Collins" <mikec@kr8.co.uk>
From: "Mike Collins" <mikec@kr8.co.uk>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: TTimers and Critical Sections...
Date: Thu, 5 Feb 2004 23:46:18 -0000
Lines: 33
Organization: kr8
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 81.2.78.34
Message-ID: <4022d173$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1076023667 81.2.78.34 (5 Feb 2004 15:27:47 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail