By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,940 Members | 1,522 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,940 IT Pros & Developers. It's quick & easy.

Control.Invoke messages: how are they buffered?

P: n/a
I have a worker thread running a POP3 mail retriever that raises a NewEmail
event every time a message is retrieved. The NewMail handler updates a
ListView in my form with a line representing the new message.

I'm using Control.Invoke properly in the NewEmail handler, but I'm concerned
about the worker thread sending more events than can be handled by the UI
thread. There is a special sorting routine that runs every time the list is
updated. As the list fills up with hundreds of messages, this calculation
can take a long time, and during that time the worker thread is still
sending Invoke requests. Will the UI thread ever "miss" an Invoke() request
because it is preoccupied with a CPU-intensive calculation? I don't know
enough about what Invoke() actually -does- to know whether the requests are
queued, pumped, or what. I just don't want my list to be outdated because a
NewMail event was lost, due to the UI thread being too busy.

--
Jeff S.
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Jeff Stewart" <ja*@micronovatech.com> wrote
I have a worker thread running a POP3 mail retriever that raises a NewEmail
event every time a message is retrieved. The NewMail handler updates a
ListView in my form with a line representing the new message.

I'm using Control.Invoke properly in the NewEmail handler, but I'm concerned
about the worker thread sending more events than can be handled by the UI
thread. There is a special sorting routine that runs every time the list is
updated. As the list fills up with hundreds of messages, this calculation
can take a long time, and during that time the worker thread is still
sending Invoke requests. Will the UI thread ever "miss" an Invoke() request
because it is preoccupied with a CPU-intensive calculation? I don't know
enough about what Invoke() actually -does- to know whether the requests are
queued, pumped, or what. I just don't want my list to be outdated because a
NewMail event was lost, due to the UI thread being too busy.


Do some testing to see if a delayed response will drop a call. Set up a
method that sleeps for half a second and use a second thread to call it
10 times passing in the number of the call. If your delayed routine sees
all the numbers 1-10, then none were missed....

LFS
Nov 21 '05 #2

P: n/a
I'd be curious to know if Windows provides any kind of indicator when/if a
dropped message occurs.

But getting back to the actual mechanism: what does Invoke() actually cause
the main thread to do? Total shot in the dark: is a message added to the
thread's pump? (If so, is there a constant somewhere that tells the capacity
of the pump?)

I seem to remember from my early Win32/MFC days that there were ways to have
Windows drop messages if other messages of the same type were also present,
effectively making Windows only respond to the most recent event of that
type. Did I imagine that?

--
Jeff S.

"Larry Serflaten" <se*******@usinternet.com> wrote in message
news:<uD**************@tk2msftngp13.phx.gbl>...
Do some testing to see if a delayed response will drop a call. Set up
a method that sleeps for half a second and use a second thread to call
it 10 times passing in the number of the call. If your delayed
routine sees all the numbers 1-10, then none were missed....

LFS

Nov 21 '05 #3

P: n/a
I believe all calls are queued up just like windows messages and processed
in order. Hence, AFAIK, there shouldn't be any "dropped" calls. Here's a
blog post on this:
http://weblogs.asp.net/justin_rogers...es/126345.aspx

Its pretty long and detailed - probably more than you asked for.
hope that helps..
Imran.
"Jeff Stewart" <ja*@micronovatech.com> wrote in message
news:1099681317.GtH1n3fzi945t14iliz8RQ@teranews...
I have a worker thread running a POP3 mail retriever that raises a NewEmail event every time a message is retrieved. The NewMail handler updates a
ListView in my form with a line representing the new message.

I'm using Control.Invoke properly in the NewEmail handler, but I'm concerned about the worker thread sending more events than can be handled by the UI
thread. There is a special sorting routine that runs every time the list is updated. As the list fills up with hundreds of messages, this calculation
can take a long time, and during that time the worker thread is still
sending Invoke requests. Will the UI thread ever "miss" an Invoke() request because it is preoccupied with a CPU-intensive calculation? I don't know
enough about what Invoke() actually -does- to know whether the requests are queued, pumped, or what. I just don't want my list to be outdated because a NewMail event was lost, due to the UI thread being too busy.

--
Jeff S.

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.