Re: Threading Issue with ArrayList

From: Eric (ejnmarquis_at_yahoo.com)
Date: 05/08/04


Date: Sat, 8 May 2004 01:05:45 -0500

Thanks to everyone who helped me with this. Especially Nicholas, Scott, and
Brad!

The older version of this app uses polling that was done within a loop that
handled socket reads and would timeout on a given interval and check for
messages during that loop. Currently, the sockets are implemenetd on a lower
level and the application itself doesn't concern itself with when the socket
read operations time out, so there is no loop in the application logic.

I could setup a messaging system again that uses polling, but I would rather
not if I could avoid it. I'd much rather have an event-triggered model where
messages are sent immediately and other threads are aware of that message
immediately rather than endlessly checking every x milliseconds. Has anyone
implemented anything like this before?

Perhaps I could implement IAsyncCallback? But that would mean a new thread
for every message sent and that seems wasteful (we're talking about a lot of
messages here).

"Brad Williams" <spam@spam.com> wrote in message
news:c7groe$l0f$1@news01.intel.com...
> You don't have to block, by using a WaitXXX method with a zero timespan
and
> then watch the return value. This becomes a polling pattern, which
assumes
> you have some loop of code in which to do the polling.
>
> Brad Williams
>
>
> "Eric" <ejnmarquis@yahoo.com> wrote in message
> news:eAG$o7GNEHA.2736@TK2MSFTNGP11.phx.gbl...
> > AutoResetEvent or ManualResetEvent would be good, but I can't block the
> > thread waiting until a message is received. All threads operate
> > independently and simultaneously and must execute continuously. A
message
> > could come at any time, it isn't planned or predictable so I can't wait
> > around for it. In the meantime, the thread is servicing user requests
from
> > the connected sockets.
> >
> > "Scott Allen" <bitmask@[nospam].fred.net> wrote in message
> > news:6hln90lvidt6mvsousk374hgqtsh6i5918@4ax.com...
> > > Not exactly, the Invoke / BeginInvoke methods on winform controls
> > > actually post messages to the UI message pump.
> > > If you are looking to signal another thread, perhaps you could use
> > > AutoResetEvent or ManualResetEvent in System.Threading.
> > >



Relevant Pages