473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Control.Invoke messages: how are they buffered?

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

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Ron Vecchi | last post by:
I am creating a control to mimic the vs.net MainMenu . The control inherits from control. Is it possible to recieve windows messages when the menu loses focus. I am running into problems after...
0
by: Duncan Mole | last post by:
Hi, I have created a control which draws a title bar and provides a drop down menu for a Smart Device Application. It seemed to work fine until I came to add an event handler to act on Paint...
2
by: rawCoder | last post by:
Hi I am having this InvalidOperationException with message Cannot call Invoke or InvokeAsync on a control until the window handle has been created This is raised when i try to invoke a method...
1
by: Chuck | last post by:
I am creating a pub/sub broker implementation in C# and I am having some trouble understanding how I should best implement the invoke portion in order to make sure it is as thread-safe as it can...
4
by: pank7 | last post by:
hi everyone, I have a program here to test the file IO(actually output) with buffer turned on and off. What I want to see is that there will be obvious differece in time. Here I have an input...
9
by: john doe | last post by:
I have a question about BeginInvoke method found on the Control class. To quote the docs: "Executes the specified delegate asynchronously with the specified arguments, on the thread that the...
2
by: =?Utf-8?B?a2VubmV0aG1Abm9zcGFtLm5vc3BhbQ==?= | last post by:
vs2005, c# Trying to understand why one way works but the other doesnt. I have not tried to create a simpler mdi/child/showdialog app for posting purposes (I think even this would not be so small...
7
by: Ben Voigt [C++ MVP] | last post by:
As much as the CLR team assures us that it's ok to fire-and-forget Control.BeginInvoke, it seems it isn't. Maybe this is a bug. See for example: the comments in...
4
by: Grant Edwards | last post by:
When I ssh in to my Windows XP box and run Python apps, output from "print" and and "sys.stdout.write()" is being buffered so that none of the output shows up until the program exits. From...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.