Threading STL Queue
-
Hi, I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application. Thanks, Ratheesh.
-
Hi, I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application. Thanks, Ratheesh.
ratheeshnair123 wrote:
I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application.
Nice to know. And what is the question?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
ratheeshnair123 wrote:
I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application.
Nice to know. And what is the question?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Hi, i am using MFC application in this application i need to display the received messages from the server (may be a chance for receiving more than one messages at a time) i need to display the received and send messages in the Listbox. i tried it in normal way, but the UI getting freezed after some time. I can able to log that message. So i tried it in some other way, like using queue the received messages are added in the queue and at thet time timer is running and one thread will pop the pushed messages in to the ListBox. Using thread how can i get the pushed value? Thanks, Ratheesh.
-
Hi, i am using MFC application in this application i need to display the received messages from the server (may be a chance for receiving more than one messages at a time) i need to display the received and send messages in the Listbox. i tried it in normal way, but the UI getting freezed after some time. I can able to log that message. So i tried it in some other way, like using queue the received messages are added in the queue and at thet time timer is running and one thread will pop the pushed messages in to the ListBox. Using thread how can i get the pushed value? Thanks, Ratheesh.
You should add the messages to the queue using a worker thread, then notify it to the GUI thread (using, for instance
PostMessage
). TheGUI
thread eventually pops messages from the queue and displays them. of course you've to lock in same way queue access. :)If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi, I pushed some string values in to the STL Queue. Now i need to pop the values from that queue using thread in MFC application. Thanks, Ratheesh.
it's probably not safe AS-IS. (stl is not by design thread-safe) I suggest you implement a simple synchronization mechanism (see Thread Synchronization for Beginners[^] )
This signature was proudly tested on animals.