andras toth schrieb:
Hi Klaus, Thanks for clarifying it. I need to know whether the thread is already running, because I use threads to fetch content from a server when the user clicks on a button. And if the button is clicked again whilst the previously started thread is not finished yet, I want to return without doing anything. On the other hand, if no fetching thread is actually running, I start a new one. And I would prefer not to put a join on the actually running thread, before starting a new one, because then the user interface would hang in case of a second request.
Well,I personally would just start and use one single thread throughout the whole application's lifetime in this case. Also I would rather use messages between threads, this makes your life with threads much easier.
With this in mind, I can think of three possibilities how to handle your situation:
1) disable the button as long as a server request is pending2) send multiple asynchronous messages to the worker thread that executes these messages one by one and sends back the answer 3) maintain a flag telling you in your main application whether your worker thread has already finished the server request
Klaus