please send me a good solution

hi all,

I have an application in which the worker threads are created using
Win32 API and the main thread is actually a GUI in MFC. I have to Send
Messages from worker threads to WinMain thread quite frequently . I
earlier used SendMessage() function but my application used to hang
frequently. So instead I used PostMessage() function, the application
works well enough now .. but still in some cases it hangs. I tried to
debug the condition and found that my WinMain stucks in the
AfxPumpingMessage function. I don't know what to do?
Can anyone suggest a workaround for this situation. ??
Thanks and Regards, 

Amod

0
9/14/2006 3:15:14 AM
vc.mfc 33608 articles. 0 followers. Follow

3 Replies
455 Views

Similar Articles

[PageSpeed] 20

Amod wrote:
> hi all,
> 
> I have an application in which the worker threads are created using
> Win32 API and the main thread is actually a GUI in MFC. I have to Send
> Messages from worker threads to WinMain thread quite frequently . I
> earlier used SendMessage() function but my application used to hang
> frequently. 

Using SendMessage is definitely a bad move, since your worker thread 
would process the message. And since the worker thread should not meddle 
with the GUI (the reason being that GDI isn't thread-safe), you would 
probably end up with some horrible crash (in regard of tracking the 
bug). So always use PostMessage.

> So instead I used PostMessage() function, the application
> works well enough now .. but still in some cases it hangs. I tried to
> debug the condition and found that my WinMain stucks in the
> AfxPumpingMessage function. 

What do you mean by this? AfxPumpingMessage is called quite frequently, 
since it is used to ask for new messages.

> I don't know what to do?
> Can anyone suggest a workaround for this situation. ??

We need a bit more information. What exactly is the erroneous behaviour 
of your application (is it freezing, throwing some exception, 
terminating ...)

Regards,
Stuart
0
DerTopper (96)
9/14/2006 9:27:49 AM
Make sure that any data that you want the UI thread to access is still 
available when the UI thread needs it.  In other words, there may be some 
time between the time you post the message and the time the UI thread 
handles it.  If the data is deleted or modified you will get unexpected 
results.  I don't know if this is your specific problem or not, but I think 
it is worth noting.

Tom

"Amod" <amod.gadre@gmail.com> wrote in message 
news:1158203714.426019.126840@e63g2000cwd.googlegroups.com...
> hi all,
>
> I have an application in which the worker threads are created using
> Win32 API and the main thread is actually a GUI in MFC. I have to Send
> Messages from worker threads to WinMain thread quite frequently . I
> earlier used SendMessage() function but my application used to hang
> frequently. So instead I used PostMessage() function, the application
> works well enough now .. but still in some cases it hangs. I tried to
> debug the condition and found that my WinMain stucks in the
> AfxPumpingMessage function. I don't know what to do?
> Can anyone suggest a workaround for this situation. ??
> Thanks and Regards,
>
> Amod
> 


0
tserface (3861)
9/14/2006 3:00:01 PM
Stuart Redmann wrote:


> Using SendMessage is definitely a bad move, since your worker thread 
> would process the message. And since the worker thread should not meddle 
> with the GUI (the reason being that GDI isn't thread-safe), you would 
> probably end up with some horrible crash (in regard of tracking the 
> bug). So always use PostMessage.

Not true. Both SendMessage and PostMessage change the thread context. 
You do need to be careful not to block your application when using 
SendMessage(), but you certainly can use SendMessage() from a worker 
thread to update the GUI in the main thread. Its one big advantage is 
data concurrency -- the worker thread cannot change (or destroy) the 
data before the GUI displays it.

David Wilkinson
0
no-reply8010 (1791)
9/16/2006 5:13:27 PM
Reply:

Similar Artilces:

send and close
Word 2003 Hi , When you send a Word doc as an e-mail, there is a button for "Send a Copy". How can I get Word to close automatically after I click that button. Do I have to do it via code or is there another button that I can put in the tool bar. Thanks, Joel ...

Outlook 2003 trying to send nonexistant email
I have a 2 part problem but the main issue is it trying to send an email that doesn't exists. I have att DSL on XP SP2. I can send and receive email from both of my yahoo email accounts through Outlook express. In outlook 2003 I receive a sending error "connection to server was interrupted" when I try to send on either of these email accounts only and not my ATT accounts. This is a problem but my main problem is that I continually receive this error on one of my two yahoo accounts when I have outlook open. There are no emails in my outbox and I have deleted this account a...

Send #3
Messages waiting to be sent are NOT formatted in italic in the Outbox, and therefore remain in the outbox after send/receive. Hi - please tell us your version of Outlook, what service pack you have, what mode if applicable (see all this in help | about) and what kind of e-mail account you use. Bernie wrote: > Messages waiting to be sent are NOT formatted in italic in > the Outbox, and therefore remain in the outbox after > send/receive. ...

How to send a multipage newsletter in the body of an email
First, the caveats. 1. I use Outlook Express so I can't be certain that this process will work if you are using something like AOL, Juno, Netscape Mail or the like. I'm sure that it will work with Outlook even tho I haven't tested it. If you are using one of those programs and you try this, I'd be interested to hear if it worked. 2. This process could produce a hefty email. I used a four page Publisher template and the file size is about 800 KB. As you change fonts, add pictures, etc, the size will grow. 3. If your audience has their email set for text only, there'...

can i send a weekly calender to others?
I want to send a weekly calender to my collegues. How do i do this?? What version of Outlook? Do you want to send them a calendar they can open in Outlook or will a calendar in a word document do? -- Diane Poremsky [MVP - Outlook] Outlook Tips: http://www.outlook-tips.net/ Outlook & Exchange Solutions Center: http://www.slipstick.com/ Outlook Tips by email: mailto:dailytips-subscribe-request@lists.outlooktips.net EMO - a weekly newsletter about Outlook and Exchange: mailto:EMO-NEWSLETTER-SUBSCRIBE-REQUEST@PEACH.EASE.LSOFT.COM Poll: What version of Exchange server do y...

Exchange OMA error message. Please read...
When our i-700's with Pocket PC 2003 attempts to access our mail exchange server, all we receive is the following error message: " A System error has occurred while processing your request. Please try again. If the problem persists, contact your administrator. Home" mail.domain.com/exchange works fine though. We've installed the service pack 1 for exchange 2003 to attempt to fix this issue and are having the same results. Does anyone care to share how they may have overcome this exchange problem with their compatible PDAs and Exchange's OMA (Outlook Mobile Access...

DB Mail is is not working. Need help please.
I have try stop and start the db mail by executing the SPs below but no luck. Does anyone has seem the error below and how to fix it. Thanks in advance for your advise/help. --steps USE msdb; go EXECute sysmail_stop_sp; go EXECute sysmail_start_sp; go EXECute sysmail_help_queue_sp @queue_type = 'Mail'; go queue_type length state last_empty_rowset_time last_activated_time ---------- ----------- ---------------------------------------------------------------- ----------------------- ------------...

Do not have permission to send to this recipient #2
Hi there, I'm having a problem with Advanced Mailbox rights in native mode Exchange 2003 in a mixed-mode 2000/2003 AD domain. Client is Outlook 2003 on either Win2k or XP sp1/2 I would like to give a set of users permissions to a common service account mailbox from which they can generate a response "From" that mailbox (i.e., not their personal account). I do this by going to the Exchange Advanced Tab|Mailbox Rights and assigning the user Full Mailbox Access. The user is then able to add the mailbox to Outlook, except when they try to send the email FROM that account, t...

How can I send e-mail as a web page
Hi! I am in the process of creating "Newsletters", and it will be a web page/html file. Is there a way I can send this to recipients so that it will be displayed as a web page in their e-mail? Outlook express had a shortcut for this, but I cannot seem to find this function in Outlook 2003. Thanks in advance : ) You either send from within the program you created the html webpage or from within Outlook use; Insert-> File...-> select HTML file-> press little down arrow on Insert-> choose Insert as Text -- Roady [MVP] www.sparnaaij.net Microsoft Office and Microsoft Off...

please recommend a voicemail software?
Hi all, I am wondering for productivity, which software is the best software that can record a voicemail and send it in email out to the recipient? I did not find this feature in Outlook 2003, I also checked OneNote, it can allow recording, but does not have a "send to recipient" feature; I have tried sticky note, it allows for recording, but does not have a button for sending it as an attachment of an email... Which is the best software of doing this in a fastest way without too many copy&paste and mouse clicks...? I hope the whole process can be streamlined and if it ...

Exchange fails to send CRM emails
When I try to send emails using the CRM 3.0 web interface "most" of them fail to be sent. If I copy that exact same and email and send it to the same address using outlook 2003 it sends with no problem. Exchange 2003 will send me an email, a day later that is is delayed and then finally another day later that it failed. I have turned off the email tracking in CRM and this did not help. I thought the numbers CRM puts in the subject may have been causing it to be blocked. What could be causing the emails to fail when sent using CRM and the exact same email to work with Outlook...

cannot send or receive mail
I configured my Outlook 2003 the same as my Outlook express that has been running successfully for years. I can create mail and it remains in the outbox even after send/receive button is pushed. No error message at all. Just no action and when I close it I do get told that there are messages waiting to be sent. ...

outbox won't send
I can not empty the outbox when I send mail. I can do each one seperately. The problem I belive is the outbox is not included in the send receive group. Outlook 2002 will not allow me to add it either. is there a way to unlock or unblock this??? ...

Choose Profile Message When Sending Report to Mail
We are having a problem with Mail Configuration. We are using GP published through Citrix. We log into the desktop as a particular user, and configure the default Mail Profile using Mail in the Control Panel, which is Outlook. The problem is that whenever we Print a report to Screen, then go Send Mail as text, it pops up with the Choose Mail dialog. After clicking on Options (on the Dialog) you can check "Default Profile" and it sends the email. Yet when we close GP and re-open it, the Choose Profile dialog appears again. Any ideas why this is happening? Regards Konrad Konr...

Suggest a solution
Hi all. I have a table named Articles that has the fields: ArticleID, ArticleName, Price and so on.... What I want to do is to make a new table that would hold some related Property records for each article. For example... Color, Weight, Length,.. This is not a problem, but what I want is to be able to change fields names for the second table (like PropertyID, PropertyName) and be able to search among those values from query. This is the most important part: ---------------------------------------------------------------- I would like to have them as a field in query from ...

Exchange 2003
Send As permission didnt set but all users are able to send as another user. Anyone encountered this before? Any solution? On Mon, 17 Jul 2006 22:42:01 -0700, Fui Fan <FuiFan@discussions.microsoft.com> wrote: >Send As permission didnt set but all users are able to send as another user. >Anyone encountered this before? Any solution? If everyone can do this you may have the all users (if there is one) security group inside an Exchange group you shouldn't. Look on the properties of a user account (yours perhaps) and see what groups have "Mull Mailbox Access". Nobody...

Create your personal SMS homepage, let friends send FREE text message to your mobile phone by web
Create your personal SMS homepage, let friends send FREE text message to your mobile phone by web Support over 147 countries and ALL languages (unicode encoding) MSG.to provides a unique personal SMS URL for you. It is easy for friends sending text message to you by web. For example, if your name is Lisa, you can register: http://MSG.to/Lisa (you can use this link to see demo) You can also register your mobile phone number as SMS URL like: http://MSG.to/+886913123456 (you can use this link to see demo) Please visit http://msg.to/ for more information. Related keywords: Short Message Serv...

Microsoft
Microsoft - ARE YOU LISTENING? 1/2. PLEASE DO THIS!!!!! You need to display a flag when the "Process thru EDC" box is not checked. Inform the cashier that the transaction is not being processed; do they want to continue? Look on the newsgroups to see how many retailers have lost credit card revenue because this box was not checked and not discovered until much later. Since all the card numbers are masked (as they should be) there is not a chance that we can recoup these losses. Yes, this did happen to me; and yes, I lost a lot of money. 1. Please make all input fields co...

How do I get outgoing messages to send from a particular email ac.
I have multiple email accounts set up in Microsoft Office. Whenever I compose new mail, it is outgoing from one of them, but as I rarely use that internet service anymore, I want it to come from another one. How do I change what email address is displayed on my outgoing messages? State your Outlook version and, if 98 or 2000, the mode (help->about->second line should say.) --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without read...

Sending but not receiving
Hi there!, I can send email to an especific person, he receives it, but i can't receive only his email. I checked already if his account was on my blocked sender list, but he isn't there. I'm using Outlook express, Full Updated. I have reset all my internet settings, and options. Nothing. Still not getting "his email only". By the way, this other person is using Outlook XP Standard edition, and we checked together all the options and settings and it looks like the emails he sends to me are going out without a problem; but i still don't get it !!! Please Help !...

Outgoing emails not sending for outlook express 2000
Hi there, Can anyone help me?Everytime I try to send an email these error messages pop up and I have no idea what to do; The host 'SMTP' could not be found. Please verify that you have entered the server name correctly. Account: 'POP3', Server: 'SMTP', Protocol: SMTP, Port: 25, Secure(SSL): No, Socket Error: 11001, Error Number: 0x800CCC0D The host 'POP3' could not be found. Please verify that you have entered the server name correctly. Account: 'POP3', Server: 'POP3', Protocol: POP3, Port: 110, Secure(SSL): No, Socket Error: 11001, Err...

granting users Send as permissions causes errors unless they select the FROM address from the GAL
I've got some users who have two mailboxes, each with a different address. They need to be able to select which address they send from, on occasion. I've given them "send on behalf" and "send as" permissions the 2nd accounts. But, unless they select the FROM address from the GAL, they get the following error: You do not have permission to send to this recipient. If they manually type in the address, they receive this error. This is only a problem because I would prefer to hide the 2nd account from the GAL, to avoid confusion. Does anyone know a way around this?...

Cannot send message
Please advise how to engage. My crystal ball is broken. Please post the error message in its entirety. You can left click on it to highlight and then right click to copy and then paste it into this thread. -- Bruce Hagen MS-MVP [Mail] Imperial Beach, CA "Joe" <jftodd@vermontel.net> wrote in message news:OR%23Ltbi7KHA.1316@TK2MSFTNGP02.phx.gbl... > Please advise how to engage. Get down on one knee, give her a diamond ring. -- Dave N. MS-MVP (Mail) Windows 7 Ultimate http://download.live.com/wlmail "Joe...

NEED HELP/SQL UPGRADE/PLEASE!
Tried to upgrade to 2.0 last night, and am running into a major difficulty getting SO Admin to talk to SQL Server 2005. My error message is "SQL Server does not exist or access denied. Connection open (Connect())" I have been on the phone with Microsoft Tech Support for most of the day (and we have been running the store without a computer, which is no mean feat). Have installed and removed SQL 2005 several times, checked to make sure everything is running and started, that everything that is supposed to be is enabled.....any insights out there? By the way, it would be a goo...

Send email to same domain name (Expert only)
Hi all, My environment as below: Internal domain name abc.com and server is ex1 External domain name abc.com and email is test@abc.com, server is ex2 Question: I have setup outlook 2003, ex1 using exchange mode and ex2 using pop3 mode, it seem ok for internal or external mail's, but i found that if ex1 no mailbox of test@abc.com, the return message is can't delivery this mail. How can i send email in test@abc.com which ex2 server can recevied? I feel that ex1 server is received the email first!!! Pls advise Hi, This should help: http://support.microsoft.com/?id=321721 Lei...