Re: Separate threads only run with DoEvents
From: Charles Law (blank_at_nowhere.com)
Date: 04/16/04
- Next message: Ben Amada: "Re: good threading articles?"
- Previous message: kieran: "Re: datagrids and email addresses"
- In reply to: Klaus Löffelmann: "Re: Separate threads only run with DoEvents"
- Next in thread: Klaus Löffelmann: "Re: Separate threads only run with DoEvents"
- Reply: Klaus Löffelmann: "Re: Separate threads only run with DoEvents"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Apr 2004 10:36:07 +0100
Hi Klaus
It calls WaitCommEvent and then WaitForSingleObject with INFINITE as the
second parameter.
The thread that it is on is started when the port is opened, so it is always
looking for data. The thread is marked as IsBackground = True.
Charles
"Klaus Löffelmann" <fornewsgroups@loeffelmann.de> wrote in message
news:OMtWuN5IEHA.2480@tk2msftngp13.phx.gbl...
> Charles,
>
> how does the background thread receive the data. Is it somehow connected
to
> the message pump of the UI-Thread?
>
> Klaus
>
> "Charles Law" <blank@nowhere.com> schrieb im Newsbeitrag
> news:%23FcthK5IEHA.3820@tk2msftngp13.phx.gbl...
> > I know I have brought this one up before, but I didn't get an answer
last
> > time, so hopefully I will have better luck this time.
> >
> > I send data out of a serial port on my main thread. I wait for a
response
> on
> > a background thread. While my main thread is waiting (only 100ms) it
sits
> in
> > a loop calling DoEvents and testing a flag.
> >
> > The background thread looks at the incoming data, and when it recognises
> > something it sets a flag.
> >
> > Meanwhile, the main thread sees that the flag has been set and processes
> the
> > response. All well and good.
> >
> > But if I replace the call to DoEvents with Thread.Sleep(10) it doesn't
> work
> > anymore. The background thread never gets a sniff at the data. Why would
> > that be? I thought the point of multi-threading was that you didn't need
> to
> > 'yield' to allow another thread to get processing time.
> >
> > Incidentally, please feel free to criticise the overall technique I have
> > described. I'm not totally happy with it myself, so any suggestions are
> > welcome.
> >
> > TIA
> >
> > Charles
> >
> >
>
>
- Next message: Ben Amada: "Re: good threading articles?"
- Previous message: kieran: "Re: datagrids and email addresses"
- In reply to: Klaus Löffelmann: "Re: Separate threads only run with DoEvents"
- Next in thread: Klaus Löffelmann: "Re: Separate threads only run with DoEvents"
- Reply: Klaus Löffelmann: "Re: Separate threads only run with DoEvents"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|