PostThreadMessage
-
Recently, I wrote on message board, that I had problem PostThreadMessage. It did not post to the thread as expected, but GetLastError did not indicate that an error has occurred. The bug disappear when I used: Sleep(20); to force it sleep for 20 ms. But when I tested it using larger test data, the same problem occurred, even more serious then before. Furthermore the performance eroded to point that it was better off not using threads. In both cases, resources was critically reduced. The "apparent" culprit was that the low resources. As the rate messages entering the message queue was higher than it's removal through processing, net increase in queue. Each message can contain significant amounts of data (up to 20k) and hence low resources. I have checked carefully there is no memory leakage so this was the only conclusion I could draw. Closer study also showed that SendMessage also failed under these circumstances. What I want to ask, 1, Has anyone else had this sort of problem? 2, Is my conclusion correct? 3, Is there a fix for this? Thank you! Any reply is greatly appreciated Kind regards, wilche :) The more simple things are, the more complex is the way it works. The more complex things are, there is probably a simpler solution.
-
Recently, I wrote on message board, that I had problem PostThreadMessage. It did not post to the thread as expected, but GetLastError did not indicate that an error has occurred. The bug disappear when I used: Sleep(20); to force it sleep for 20 ms. But when I tested it using larger test data, the same problem occurred, even more serious then before. Furthermore the performance eroded to point that it was better off not using threads. In both cases, resources was critically reduced. The "apparent" culprit was that the low resources. As the rate messages entering the message queue was higher than it's removal through processing, net increase in queue. Each message can contain significant amounts of data (up to 20k) and hence low resources. I have checked carefully there is no memory leakage so this was the only conclusion I could draw. Closer study also showed that SendMessage also failed under these circumstances. What I want to ask, 1, Has anyone else had this sort of problem? 2, Is my conclusion correct? 3, Is there a fix for this? Thank you! Any reply is greatly appreciated Kind regards, wilche :) The more simple things are, the more complex is the way it works. The more complex things are, there is probably a simpler solution.
wilche wrote: PostThreadMessage. It did not post to the thread as expected, but GetLastError did not indicate that an error has occurred. Does the thread in question has it's message queue created. That is does it call any of GetMessage, PeekMessage etc. functions before you call PostThreadMessage from other threads. That might be the problem.
-
wilche wrote: PostThreadMessage. It did not post to the thread as expected, but GetLastError did not indicate that an error has occurred. Does the thread in question has it's message queue created. That is does it call any of GetMessage, PeekMessage etc. functions before you call PostThreadMessage from other threads. That might be the problem.