Re: Separate threads only run with DoEvents
From: Klaus Löffelmann (fornewsgroups_at_loeffelmann.de)
Date: 04/16/04
- Next message: Jay B. Harlow [MVP - Outlook]: "Re: error in me.show()"
- Previous message: Armin Zingler: "Re: Separate threads only run with DoEvents"
- In reply to: Charles Law: "Re: Separate threads only run with DoEvents"
- Next in thread: Charles Law: "Re: Separate threads only run with DoEvents"
- Reply: Charles Law: "Re: Separate threads only run with DoEvents"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 16 Apr 2004 14:43:18 +0200
Charles,
see Armins reply.
Klaus
"Charles Law" <blank@nowhere.com> schrieb im Newsbeitrag
news:uADy$Y5IEHA.3040@TK2MSFTNGP09.phx.gbl...
> 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: Jay B. Harlow [MVP - Outlook]: "Re: error in me.show()"
- Previous message: Armin Zingler: "Re: Separate threads only run with DoEvents"
- In reply to: Charles Law: "Re: Separate threads only run with DoEvents"
- Next in thread: Charles Law: "Re: Separate threads only run with DoEvents"
- Reply: Charles Law: "Re: Separate threads only run with DoEvents"
- Messages sorted by: [ date ] [ thread ]