Re: Separate threads only run with DoEvents

From: Charles Law (blank_at_nowhere.com)
Date: 04/16/04


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
> >
> >
>
>



Relevant Pages

  • Re: Wininet PORT command
    ... I am now using the INTERNET_FLAG_PASSIVE flag so that it uses PASV instead ... I wanted it to be using PASV anyway. ... One group of people complained that there is no way to force PORT and so ... I cannot reproduce *exactly* the same environment, ...
    (microsoft.public.win32.programmer.networks)
  • iptables and firewall coonfiguration so thatit understand when ssh logs in properly and when not
    ... basically i have a little home network and i have forwarded port 22 to ... timestamp to current time and wait 300secs before reseting the flag. ... so i won't get a login screen. ...
    (comp.os.linux.networking)
  • Re: D-Link DI-804HV Router Firewall SPI Function
    ... > Charles wrote: ... One of the features that I hoped would help is ... A firewall that uses Stateful Packet Inspection ... > "This port has not responded to any of our probes. ...
    (comp.security.firewalls)
  • Re: D-Link DI-804HV Router Firewall SPI Function
    ... > Charles wrote: ... A firewall that uses Stateful Packet Inspection ... > closed port, your router will transmit back an RST packet saying "no, you ... > closed instead of stealth, it's not the end of the world. ...
    (comp.security.firewalls)
  • Re: Question about International Cruising such as Bahamas, Canada ..
    ... continue on to your chosen port of entry. ... flew the yellow Q flag. ... courtesy flag, we always fly that as we sail into a country's waters. ... Sometimes we have even been sewing it up as we neared Customs. ...
    (rec.boats.cruising)