🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

aborting a function

#14902
From: Robert L. Smith
Date: Fri, 25 Jul 2003 22:04
47 lines
2036 bytes
I have a function which talks to some remote hardware through a serial port:



int talk_to_hardware(void)



Because it uses the serial port, this function is not re-entrant.  It takes
anywhere from 10 msec to several seconds to execute.  Calling this function
from a ButtonClick event handler means a user can click faster than the
function executes.  It is required that the extra overlapping calls be
executed eventually and not simply discarded.



There is also a requirement to add an abort function to terminate the serial
communication:



void abort_talking(void)      // typically called from AbortButtonClick



This should halt the currently executing talk_to_hardware and abort any
pending calls.



Is there a simple way to meet all these requirements?



If abort_talking sets a global bool flag, then calling
Application->ProcessMessages from inside talk_to_hardware can detect an
AbortButtonClick but will also try to execute pending ButtonClicks.  More
complicated approaches using threads and/or Windows messaging also haven't
worked.  Any suggestions?



Thanks in advance,



Robert L. Smith
Technical Details
Message-ID: <3f21a974@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!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,cb957e45a585bf2c,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-25 15:09:47 PST
From: "Robert L. Smith" <bsmithOMIT@cinSPAMele.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: aborting a function
Date: Fri, 25 Jul 2003 18:04:35 -0400
Lines: 51
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: 66.117.195.80
Message-ID: <3f21a974@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1059170676 66.117.195.80 (25 Jul 2003 15:04:36 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-01!sn-xit-08!supernews.com!newsfeed.online.be!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail