Re: Wait for flag
From: Martin James (mjames_falcon_at_dial.pipex.com)
Date: 11/05/03
- Next message: Rob Kennedy: "Re: Get errorcode after ShellExecEx returns"
- Previous message: Jerry Blumenthal: "Get errorcode after ShellExecEx returns"
- In reply to: maccor.com>: "Wait for flag"
- Next in thread: Peter Zolja: "Re: Wait for flag"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 5 Nov 2003 14:31:02 -0000
"maccor.com>" <j.munk@<remove this> wrote in message
news:3fa90609$1@newsgroups.borland.com...
> How do I most efficiently let the main thread of an application to wait
for
> another thread to raise a flag (to signal that data are ready)? Right now
I
> just loop until the flag (a byte) is set or a time out reached, but just
> spinning a loop takes a lot of system resources although it is typically
not
> for much longer than 50ms at the time.
Post a message to fire a message-handler event. Main-thread event handlers
should not wait. If you have a need to wait, you need to change your design
to be event-driven.
> Another way to do it could be to suspend the main thread for e.g. 40ms,
but
> although you can suspend threads you have created yourself, I don't see
how
> you can suspend the main (i.e. application thread)
Well, you *could* suspend it, but I wouldn't recommend it. The main thread
should be handling the GUI, not polling threads.
> FYI, what I need it for is to communicate between two applications on two
> computers (one cound be embeded), so I send out a request for data and
then
> I wait until I get the data received event.
Two computers? What are you using to communicate between them? IP/sockets?
Some shared bus?
Need input..
Rgds,
Martin
- Next message: Rob Kennedy: "Re: Get errorcode after ShellExecEx returns"
- Previous message: Jerry Blumenthal: "Get errorcode after ShellExecEx returns"
- In reply to: maccor.com>: "Wait for flag"
- Next in thread: Peter Zolja: "Re: Wait for flag"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|