473,785 Members | 2,484 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1140

"Jeff Stewart" <ja*@micronovat ech.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*******@usin ternet.com> wrote in message
news:<uD******* *******@tk2msft ngp13.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*@micronovat ech.com> wrote in message
news:1099681317 .GtH1n3fzi945t1 4iliz8RQ@terane ws...
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
1346
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 the tab key is hit, the menu loses focus and does not respond to messages untill focus is regained. This is not desireable since hotkeys should open menus. Also, I would like to stay away from p/invoke for use with linux's mono project. ...
0
1907
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 messages in the form which has drawn the control. Evidently, the control is consuming all of these messages. How can I pass them back/on? I have a reference to the owner form but calling Refresh() via this reference isn't helping. Help! Do I need to...
2
3009
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 with arguments I need to do this as the method is being called Asynchronously from elsewhere using delegate's BeginInvoke method. The form is well created/initialized yet the messages states otherwise.
1
1567
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 be. The "broker" class allows other objects to subscribe to messages that will get published by other objects. To subscribe they pass in a Object that represents thier instance (aka 'this') and a String that contains the method name to be...
4
4196
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 file scales 1.1M, what I did is just copy it to another output file(ten times). But I don't think I see any difference. My file system is ext3, with debian sarge(kernel-2.6.8). Here is the main part of my program:
9
5668
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 control's underlying handle was created on." Which is fine, but I'm wondering how does this method get called asynchronously if it's on the same thread we are working on? Surely it blocks the thread until returned?
2
4426
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 or simple). I am hoping the description will generate some ideas I can check out. PROBLEM: ----------------- Switching to UI thread using Invoke(), everything seems good.
7
5676
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 http://blogs.msdn.com/cbrumme/archive/2003/05/06/51385.aspx I was encountering a bug that disappeared when debugging. Not when a debugger is attached, mind you, but when I placed a breakpoint near the code. Adding Trace.WriteLine statements showed that the failing code was...
4
1598
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 within my program how do I set output buffering to either line-buffered or un-buffered? -- Grant Edwards grante Yow! I'm rated PG-34!! at
0
9645
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10325
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9950
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7499
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6739
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4050
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.