Board index » delphi » Doing two things at once in D3

Doing two things at once in D3

I'm trying to build a program that'll send a packet out of the serial port
every second (using Async Pro).  At the same time, I'd like to load up files
using an opendialog box.  I still want to be sending the packet every
second, even when I'm searching for the file to open (& also whilst the
file's loading).

What's the best way to do this?  Do I run the packet tx section in another
thread or is there an easier way?!

Jim

 

Re:Doing two things at once in D3


In article <902268288.23814.0.nnrp-05.9e985...@news.demon.co.uk>, "Jim Main"

Quote
<j...@ewcomm.demon.co.uk> writes:
>What's the best way to do this?  Do I run the packet tx section in another
>thread or is there an easier way?!

Sounds like an ideal situation for multi-threading - which is not going to be
complex for what you're trying to do. Simply go File|New|Thread object, stick
your comm port code in the Execute method, create the object and you're away!

Charles Johnson

Re:Doing two things at once in D3


Can't say I am an expert on threading, but it sounds like all you need to do
is plop a timer on your main form, start it running, and every time it
expires, write your packet to the async pro port.  (all of the asyc pro stuff
is threaded, as i recall, so from there you have no worries.) This will
execute all the time, even when dialogs are open, etc.  Timers work in an
interrupt-like manner.
Quote
Jim Main wrote:

> I'm trying to build a program that'll send a packet out of the serial port
> every second (using Async Pro).  At the same time, I'd like to load up files
> using an opendialog box.  I still want to be sending the packet every
> second, even when I'm searching for the file to open (& also whilst the
> file's loading).

> What's the best way to do this?  Do I run the packet tx section in another
> thread or is there an easier way?!

> Jim

Other Threads