Wait for Thread
-
Hello, I currently working on a program. Suprise, suprise. And this program has to wait for a client to connect and then do something with the client. I put the wait for client, etc. stuff into a thread so that my interface is still useable, but since it's a thread my main program continues running. How can I prevent this ? So the Interface of my Main Program should keep useable but it should not continue work till a client connected. Any Ideas or Suggestions ? With best regards, Benedikt
-
Hello, I currently working on a program. Suprise, suprise. And this program has to wait for a client to connect and then do something with the client. I put the wait for client, etc. stuff into a thread so that my interface is still useable, but since it's a thread my main program continues running. How can I prevent this ? So the Interface of my Main Program should keep useable but it should not continue work till a client connected. Any Ideas or Suggestions ? With best regards, Benedikt
RedDragon2k wrote:
my main program continues running
Wasn't that the whole idea of making another thread? I assume you mean you don't want the user to be able to use the UI? If this is the case just disable the main window or bring up a modal "please wait" dialog that is dismissed when the worker thread is done by sending a
WM_CLOSE
message to it. Steve -
Hello, I currently working on a program. Suprise, suprise. And this program has to wait for a client to connect and then do something with the client. I put the wait for client, etc. stuff into a thread so that my interface is still useable, but since it's a thread my main program continues running. How can I prevent this ? So the Interface of my Main Program should keep useable but it should not continue work till a client connected. Any Ideas or Suggestions ? With best regards, Benedikt
Can you use ::WaitForSingleObjectEx(...) function?
-
Can you use ::WaitForSingleObjectEx(...) function?
If he uses this API the UI will not redraw properly while the worker is running. Steve
-
Hello, I currently working on a program. Suprise, suprise. And this program has to wait for a client to connect and then do something with the client. I put the wait for client, etc. stuff into a thread so that my interface is still useable, but since it's a thread my main program continues running. How can I prevent this ? So the Interface of my Main Program should keep useable but it should not continue work till a client connected. Any Ideas or Suggestions ? With best regards, Benedikt
That is easy just do not return from the thread util a client has reacted. No wait a client may never react and then you end up with an infinite loop. There are multiple ways to provide a solution to this problem, the simpilest is to disable all commands that require the client to communicate with you. That is anything that is not be dependent on an outside source, like close application. The main thread should never be disabled, because you always need the option of shuting down the program. INTP “Testing can show the presence of errors, but not their absence.” Edsger Dijkstra
-
RedDragon2k wrote:
my main program continues running
Wasn't that the whole idea of making another thread? I assume you mean you don't want the user to be able to use the UI? If this is the case just disable the main window or bring up a modal "please wait" dialog that is dismissed when the worker thread is done by sending a
WM_CLOSE
message to it. SteveHello, nice ideas. But I think they won't work, because the my app does are done silent. All in all just want the UI to be drawn correctly. And the possibility to stop the work (so interaction). Hope this helps, Benedikt