Modal dialog not always receiving user defined messages from PostMessage()

Hi everybody,

I have a simple dialog based application that reads data from a serial
port in a worker thread (MonitorSerialPort()). When the worker thread
detects data, it uses PostMessage() to send a message to a custom
class that I derived from CWnd (CSerialDataProcessor).
CSerialDataProcessor takes the raw data from the serial port and
parses it into application specific format. It then posts a message to
a modal dialog and the modal dialog in response to this message
updates a control to display the parsed data to the user.

This scheme works for the most part, however, when I stress test it,
it fails. What I do to test this architecture is comment out the
actual serial port monitoring code and instead just send fake data
(once every 10 ms) to the CSerialDataProcessor. This code works for
about 3 - 5 minutes. Then the system just dies and the dialog hangs.

When I use the Windows Spy tool, I see that the MonitorSerialPort() is
still sending the messages (even though the dialog hangs) and in turn,
the CSerialDataProcessor() is sending a message to my Dialog. However,
my message handler is not getting called.

Any ideas or suggestions for a newbie learning Windows?

Thanks in advance.
0
user2084 (3)
1/30/2005 4:57:42 PM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
1272 Views

Similar Articles

[PageSpeed] 16

I just got done monkeying around with threads.

Are you using PostMessage() or ::PostMessage(Handle, etc, etc) in your 
thread?
There is some discussion here about interprocess communications 
http://www.mvps.org/vcfaq/
SetThreadHwnd(GetSafeHwnd())  (Shows how to set an HWND in your thread 
class)
You probably need ::PostMessage in the thread, but not the 
CSerialDataProcessor Class.

There is an example of using a dialog with threads called "Mutexes".
(You might want to look at it)

What actually happens is that you pass a Dialog pointer to the thread.
The thread then updates the control without the need to send or post 
messages.
You could do that perphaps, in your CSerialDataProcessor() class?

Then, after you Serial data thread is finished, the thread would post a 
message back saying
that it is finished.


Good Luck,
-- 
Christopher J. Holland [!MVP]
http://www.mvps.org/vcfaq/
http://www.codeguru.com
http://www.codeproject.com
http://www.naughter.com/
http://support.microsoft.com/default.aspx
http://msdn.microsoft.com/howto/
http://msdn.microsoft.com/library/
www.flounder.com/mvp_tips.htm

"User 2084" <user2084@hotmail.com> wrote in message 
news:fff4b05c.0501300857.5c9c1b0@posting.google.com...
> Hi everybody,
>
> I have a simple dialog based application that reads data from a serial
> port in a worker thread (MonitorSerialPort()). When the worker thread
> detects data, it uses PostMessage() to send a message to a custom
> class that I derived from CWnd (CSerialDataProcessor).
> CSerialDataProcessor takes the raw data from the serial port and
> parses it into application specific format. It then posts a message to
> a modal dialog and the modal dialog in response to this message
> updates a control to display the parsed data to the user.
>
> This scheme works for the most part, however, when I stress test it,
> it fails. What I do to test this architecture is comment out the
> actual serial port monitoring code and instead just send fake data
> (once every 10 ms) to the CSerialDataProcessor. This code works for
> about 3 - 5 minutes. Then the system just dies and the dialog hangs.
>
> When I use the Windows Spy tool, I see that the MonitorSerialPort() is
> still sending the messages (even though the dialog hangs) and in turn,
> the CSerialDataProcessor() is sending a message to my Dialog. However,
> my message handler is not getting called.
>
> Any ideas or suggestions for a newbie learning Windows?
>
> Thanks in advance. 


0
msnews (126)
1/30/2005 10:03:07 PM
>This scheme works for the most part, however, when I stress test it,
>it fails. What I do to test this architecture is comment out the
>actual serial port monitoring code and instead just send fake data
>(once every 10 ms) to the CSerialDataProcessor. This code works for
>about 3 - 5 minutes. Then the system just dies and the dialog hangs.
>
>When I use the Windows Spy tool, I see that the MonitorSerialPort() is
>still sending the messages (even though the dialog hangs) and in turn,
>the CSerialDataProcessor() is sending a message to my Dialog.

Do your calls to PostMessage succeed?

It sounds as though you're exhausting some system resource. Do you
have any drawing code that's getting invoked?

How do you generate your data every 10mS? Is it possible that you're
filling the message queue for the dialog? How long does the program
stand up for if you slow the rate?

Dave
-- 
MVP VC++ FAQ: http://www.mvps.org/vcfaq
0
davidl7375 (2060)
1/31/2005 1:13:50 AM
Christopher:

> What actually happens is that you pass a Dialog pointer to the
thread.

Thanks for the suggestion - I'll try this.

Dave :

> Do your calls to PostMessage succeed?

Good point, I should have checked this before posting. Let me see if it
returns a failure at any point.

> Do you have any drawing code that's getting invoked?

I'm updating three static controls each time the Dialog receives a
message. I'm not directly drawing anything myself.

> How do you generate your data every 10mS?

Instead of:

while (1)
{
if (WaitForCommEvent() == DATA_RECEIVED)
{
PostMessage(); // send data
}
}

I do:

while (1)
{
Sleep(10);
PostMessage(); // send fake data
}

> Is it possible that you're filling the message queue for the dialog?

Probably, but I don't know how to check this.

> How long does the program stand up for if you slow the rate?

Last night I tested it at 1 s with no problems. Will try some of the
other suggestions and try with 10 ms.

Thanks for all the suggestions!

0
user2084 (3)
1/31/2005 6:59:04 PM
Reply:

Similar Artilces:

One user unable to send external mail
Hi Running exchange 5.5 on NT4. Have one user who suddenly cannot send external mail. All external messages get instantly bounced with the following NDR Your message did not reach some or all of the intended recipients. Subject: test Sent: 12/31/2003 11:34 AM The following recipient(s) could not be reached: '<valid address>' on 12/31/2003 11:34 AM The recipient name is not recognized The MTS-ID of the original message is: c=US;a= ;p=The Computer Par;l=LMW59-031231113340Z-15 MSEXCH:IMS:The Computer Partnership Ltd:TCPNT1:LMW59...

Recovering Deleted Messages in Outlook Express
Is it possible to recover messages that have been deleted from the deleted mail folder in outlook express? If so, how? Thanks, Bill No, sorry, not unless you made a backup of your mail store folder(s) first. Also note - This is a group to support Outlook from the Office group of programs. Outlook Express is a part of Internet Explorer and is a quite different program, despite its similar name.. You will probably get a faster and more expert answer if you post this to an Outlook Express news group. Try posting in one of these newsgroups: microsoft.public.windows.inetexplorer.ie5.outlooke...

Outlook ask for user/password
Hello, we have an user xx with password yy. With these he login on a XP Home. Why Outlook XP SP3 ask for user and password ever again, just with remember password option. Typing in user/password works, so they are correct. The outlook account is on a Windows 2000 Server with Exchange 5.5 Why Outlook do not remember the password? Sincerly Eikenberg ...

Multiple users
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel I installed a home/student version of Office. My wife installed the same and unfortunately used the same of the three product codes. Every time she uses this I get kicked off. I uninstalled Office and re-installed with the idea of entering a different product code, but it never asked for a product key code. The program is fully working, except when my wife starts using hers and I get kicked off again. How do I fix this? ...

Unable to receive emails, delete inbox items & have outbox items moved to "Sent"
[OS: Windows XP Home / Microsoft Outlook 2000] 1) Emails in the Outbox are sent but then they are not (automatically) moved to "Sent Items" after delivery, thus they are repeatedly re-sent ... NOTE: Unable to delete or move these mails from Edit --> Move to folder... 2) I am not receiving any emails. Attempts to send/ receive accompany an error message. 2) Items in the inbox can NOT be deleted ... citing an Unknown Error. Any suggestions on how to make Outlook functional again? Or, how I can start with new/clean Inbox, Deleted Items and Sent Items folders, BUT keep/main...

Setting rules for moving messages automatically
I am new to Outlook. I want to set a rule that when mail from specific individuals addressed to me can be moved automatically AFTER BEING READ to a specific folder. I would like them moved to the folder but not deleted. What are the steps in creating the rule so they dont get moved before I have "read" the message ?? Rules work on mail as received, not after being read. --=81 Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. All unsolicited mail sent to my personal account will be deleted without reading. =20 After furious head scra...

Not receiving mail from one person
I can't get mail from one person, and the other person on my wireless network can't get mail from him either. No problem before I went on vacation for two weeks. I can't find any blocks in OE or at the main server (Comcast). Everyone else can get mail from him. His mail is not showing up on the server and there is nothing in spam either. Any ideas? Thanks. If the message is not showing up on Comcast's Webmail site, OE can't get it. Any Delete It From Server rules? That's the only OE option that could do it, but if OE was closed when a messag...

Outlook Express Error Message Since Installing XP SP2
Since installing XP Service Pack 2, Outlook Express will not download my family's Hotmail accounts. The error message is displayed below. Have deleted accounts and re introduced them, have uninstalled Outlook Express and Re loaded it, have added it to the Exceptions section in the New Windows Firewall Utility and all to no avail. What have I overlooked? Redirected Configuration: Account: XXX_XXXXX Server: http://services.msn.com/svcs/hotmail/httpmail.asp User name: xxx_xxxxxx@hotmail.com Protocol: HTTPMail Port: 0 Secure(SSL): 0 Code: 80004005 -- David Wh...

Showing edits to Outlook 2007 messages
Hi All... I'm trying to find a function in Outlook 2007 that is present in Microsoft Entourage 2008 (Mac). When a received message is edited in Entourage (not a new message, but a received message) and is edited in some way, a "edit" icon is placed next to the message in message listing pane. In Outlook 2007, I can edit received messages, but after the message is edited, there is no "edit" icon next to the message. I've tried playing with the various fields options, but none of these show the data that I want to display. Any help would be MOST appreciated! Thank...

not receiving video
I have Microsoft Windows XP Professional, Version 2002, Service Pack 3 and running the latest version of windows media player 11 <11.0.5721.5268>. My problem is; I am not getting any video when choosing to play either movies or videos w/player. Any and all help is appreciated. TIA! On Sun, 10 Jan 2010 21:03:02 -0800, ldcastee <ldcastee@discussions.microsoft.com> wrote: >I have Microsoft Windows XP Professional, Version 2002, Service Pack 3 and >running the latest version of windows media player 11 <11.0.5721.5268>. My >problem is; I am not gettin...

simple way to send and receive email when exchange not available
Hmm, what's the best way to configure Outlook 2000 so that when the user is out of the office away from the Exchange 2003 server, he can: a) read and reply to previous messages (offline sync, I know about this part) b) send replys or new emails out from another connection, say dsl or cable without access to exchange. c) get any new mails that come into the exchange server I presently have only OWA setup via ssl for remote access. I also have vpn capability, but hope not to have to give this user that ability. RPC-over-HTTP, hands down. --- David L. West http://www.deskoptional.com ...

Can't move Junk Mail messages in Outlook 2002
When I try to turn on the junk mail filter in Outlook 2002, I get the message "Your are currentlyworking off line. To use this command you must restart outlook and choose to connect to the Exchange Server." I have no Exchange Server. This is a single installation on my home computer. Any ideas on how to solve? ...

Find which users are actually using a pop3 account in Exchange 200
We are using Exchange 2003 in a windows 2003 environment. We want all users on exchange, but have only about a 1/3 of them on it. For all of the users, the exchange account and the pop3 account is enabled. We want to switch the users from pop3 to exchange, but need to know who to change without walking around to all 150 users. Is there a way to find out what users are actually using their exchange account, and what users are using the pop3 account to access their email? Hi, Are these using POP3 to retrieve their mail from the Exchange server, or an external ISP of some type? ...

Admins
I'm curious to hear how other admins are handling requests from their users. Is anyone using the cases functionality to track internal cases similar to how an external case would be tracked? Hi, Its ok to use Case entity for internal use if it is not being used for external users. The other option is to create a custom entitiy. Name it may be "Internal Request". Customize it as per your requirments and than use it as for internal requests handling. -- uMar Khan :: MS CRM MVP CRM Freelance Consultant Email :: imumar at gmail dot com Blog :: http://umarkhan.wordpress.com...

Excel must be installed error message.
To make a long story short, I had to reinstall WindowsME and Office 2000 Premium. During the installation of the excel financial manager, I received the error message that Excel needed to be installed or the financial manager unchecked. I tried 1> Repairing the installation and 2> Reinstalling Office. I'm till getting error messages. Excel can be started from various shortcuts and by clicking on files, however, there is always an error now, "Compile error in hidden module: Autoexec new, and on closing "Compile error in hidden module: Dist Mon" Any ideas on how to get...

NDR, but user gets message anyway
I've tried searching for this particular problem but haven't had any luck. A few weeks ago we had several serious problems which ended up in our rebuilding our Exchange server and deleting/recreating our user accounts. All the problems that seemd to have started then have been largely solved, except for one which affects a single user. If I (or anyone) were to send an email to one particular user (we'll call her Jane), she will get the message in the normal amount of time (nearly instantly), but I'll get an NDR (5.1.2) back on her at the same time. If I (or anyone) ...

Error message when adding text to bar
-->Sorry, nothing happened when I hit the submit button, so I hit it again. sorry.<-- Microsoft Project 2000, I am trying to add text to the right of a bar in a Gantt Chart. Don't I select "Right", then scroll down and choose "Text1" change the text to what I want to say, and hit OK? When I do, I get a pop up that says "This value is not valid in this situation, Chick the field to see if it requires text, a date, or a number, and that you typed the information correctly. How do I do that? I thought I did... Thanks for your help. -...

When close Modeless Dialog, is WM_DESTROY produced?
I never catch up a WM_DESTROY message when I close a Modeless Dialog Window. What message should I check? Anyone can help me? Thanks. OnClose or WM_CLOSE should do it for you. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Frank E Rogers" <syang@pelco.com> wrote in message news:uD5yjj0eEHA.3964@TK2MSFTNGP12.phx.gbl... > I never catch up a WM_DESTROY message when I close a Modeless Dialog > Window. What message should I check? Anyone can help me? > > Thanks. > > ...

test..where are my messages..test
...

551 user not local
My user report they can't send mail outside of company. I checked the outlook, found that not all the mail can't send out. some of them are returned. the return message said that 551 user not local , mail can't deliver. I don't why. I test the same mail to hotmail.com, that's ok. can you help me solve or explain why it is. You'll have to explain in more detail the nature of the problem. Has this just started happening? Have you checked event logs or SMTP logs for more information. Is this problem consistent with certain domains? Is the problem limited to certai...

Outlook message font changes spontaneously
I can find no reference to this problem anywhere, so it may be hopeless. Outlook 2002. WinXP. All service packs and updates are installed. This occurs with Word as email editor or not. HTML, RTF makes no difference. Arial 10pt was the selected font of choice for email. Coincidentally that same font is the one used in Word normal.dot, in FrontPage, and in Internet Explorer. Start a new Outlook message. Type...type...type... After a minute or so, the font suddenly changes for all the text I have typed, as well as subsequent typing, to Times New Roman 10pt. Or type a little and th...

No Send/Receive at login
When I log into Outlook 2003 I need to click the Send/Receive button to download mail. Is there a setting to automatically do this at login? The only way to receive messages at any time is to click the Send/Receive button. I am running XP Home with the latest Office Professional 2003. Tools-Email->Send/Receive settings. What do you have defined there? You should have an automatic polling interval set (this causes the send/receive on startup) and Send Immediately both checked. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to t...

Error:Email message in CRM client for Outlook
I have the following error message “An error occurred promoting this item to Microsoft CRM. The Microsoft CRM server could not be contacted or the user has insufficient permissions to perform this action. Do you want to send the e-mail? If you click Yes, the e-mail will be sent out, but no corresponding activity will be created in Microsoft CRM.” In the article ( http://support.microsoft.com/kb/925532/ ) the Microsoft give the solution. I have done every steps described in this article but the error continues. Someone can give another solution? Thanks an advance, Paulo Pina On...

Outlook respond is slow when navigating messages within mailbox
Hi, My oulook xp was running smoothly until recently. The message become intermitent slow in navigating them ans a small little window "request data from microsoft Excahnge .." appear and says that "Outlook is retrieving data from the Microsoft Excahnge Server "Exchange1" You can cancel the request or minimise this message to the windws taskbar until Outlook closes the message automatically" It has a cancel request button. Why is it happen and how to solve this puzzle? Thanks MWGP ...

How To Open Chart Wizard Dialog on Excel 2003
Hi All, I need to open the Chart Wizard Dialog by c# code my code is the follow excel.Dialogs[mode].Show(missing x30); where excel = new Excel.Application mode = xlDialogChartWizard missing = System.Type.Missing; show has 30 args so i repeat missing 30 times this code works for the xlDialogPivotTableWizard dialog Help me pls Thx in Advance Hi, I don't know a thing about C#, but why not exclude the Show arguments? -- Cheers, Shane Devenshire "VeNoMiS" wrote: > Hi All, > I need to open the Chart Wizard Dialog by c# code > > my code is the follow > >...