Jump to content
  • Advertisement
Sign in to follow this  

Small thread snag...

This topic is 2167 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, im having a little problem with my code, ill do my best to explain. I have this virtual function OnConnectionLost() in my networking class, that contain this line of code:


// Add a string of text to a listbox

SendMessage(hListBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"Connection Lost.");



... And of course it work well when im using the single threaded version of my class.


However, when im calling it from a 2nd thread, i got a deadlock, because the main thread is blocked waiting for the 2nd thread to finish(why the main thread is blocked

is not important, but it always is when the code reach OnConnectionLost() in the 2nd thread). So, calling sendmessage block the 2nd thread, and both threads wait for each other.


My first though was to use PostMessage(), but it don't work with strings (i even tried passing a static string, to no avail).


Sooo, i don't know how to solve that. I could live with commenting this particular function, everything work just fine that way.

But if anyone know how that could be solve, that would be great.



Edited by Vortez

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!