multithreading - TThread Doesn't Do It's Job Unless there is a MessageBox in the Middle ! -


i created class of tthread socket operations, thing is, code doesnt work unless add messagebox it, sockets wont work unless put messagebox call before it

 sleep(2000); //waiting socket come array  // messagebox(0, '', '', 0); { wont work unless line uncommented }  if server.clientlist[handle] <> nil  begin   if (server.clientlist[handle].connected) , (appsocket.connected)   begin    // send data on socket    // relay data between server.clientlist[handle] , appsocket;   end;  

assuming using non-blocking sockets, thread needs running message queue , processing loop. why calling messagebox() works - modal dialog pumps calling thread's message queue internally. thread needs call peekmessage() or getmessage() in loop lifetime of connection(s). loop can use msgwaitformultipleobjects() detect when message queue has process, if thread has other things needs do.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -