What can cause SendMessage to get stuck?
-
Hi, I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI. However, after running my application for anywhere between 1/2 hr to 5 hours, SendMessage will randomly get stuck.... IE: The window that's suppossed to receive the message never receives the message, and the application GUI just freezes. Can anyone tell me if this has happened to them before, or what could possibly cause the message sent by SendMessage to not-be-received by the recepient window? Thanks, skyapie :-D
-
Hi, I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI. However, after running my application for anywhere between 1/2 hr to 5 hours, SendMessage will randomly get stuck.... IE: The window that's suppossed to receive the message never receives the message, and the application GUI just freezes. Can anyone tell me if this has happened to them before, or what could possibly cause the message sent by SendMessage to not-be-received by the recepient window? Thanks, skyapie :-D
Its called a deadlock and your thread synchronisation is not working correctly, SendMessage() will wait until the message has been processed before returning, you could try PostMessage() instead which will not wait but I would check your thread synchronisation first.
Darka [Xanya] "I am not a slave to a god that doesn't exist."
-
Hi, I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI. However, after running my application for anywhere between 1/2 hr to 5 hours, SendMessage will randomly get stuck.... IE: The window that's suppossed to receive the message never receives the message, and the application GUI just freezes. Can anyone tell me if this has happened to them before, or what could possibly cause the message sent by SendMessage to not-be-received by the recepient window? Thanks, skyapie :-D
skyapie wrote:
I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI.
Secondary threads should post messages (i.e.,
PostMessage()
) to the primary thread.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Hi, I've got 2 threads, one continuously uses "SendMessage" to tell main thread to perform some processing and update the GUI. However, after running my application for anywhere between 1/2 hr to 5 hours, SendMessage will randomly get stuck.... IE: The window that's suppossed to receive the message never receives the message, and the application GUI just freezes. Can anyone tell me if this has happened to them before, or what could possibly cause the message sent by SendMessage to not-be-received by the recepient window? Thanks, skyapie :-D
As has been said, never use
SendMessage()
to send messages between threads. UsePostMessage()
instead. If you really need the return value from the message then you can useSendMessageTimeout()
.
You may be right
I may be crazy
-- Billy Joel --Within you lies the power for good, use it!!!