Forum > General
Killing off stucked thread
balazsszekely:
--- Quote ---how could i call FPHttpClient.Terminate on a locally declared FPHttpClient?
--- End quote ---
What do you mean by "locally declared FPHttpClient"? In you original post you said: "I have a thread with a HTTP GET request inside". I assume FPHttpClient is declared inside the private section of the thread. Now all you have to do is declare a public variable like NeedToTerminate. On the setter just call FPHttpClient.Terminate, this way the HTTP GET request will exit immediately, causing the thread to terminate, unless you have something else inside the execute method of course. So basically:
1. Create/start the thread
2. Start a timer
3. When the timer ticks, just set YourThread.NeedToBreak to true
TCH:
--- Quote from: GetMem on October 02, 2017, 01:25:18 pm ---
--- Quote ---how could i call FPHttpClient.Terminate on a locally declared FPHttpClient?
--- End quote ---
What do you mean by "locally declared FPHttpClient"? In you original post you said: "I have a thread with a HTTP GET request inside". I assume FPHttpClient is declared inside the private section of the thread.
--- End quote ---
Nope, sorry, i was misunderstandable. The FPHttpClient is declared inside a separate function which is not a part of the thread, but it is available in the entire unit and the thread calls this function.
Also, does FPC 3.1.1 work under OSX 10.6?
balazsszekely:
--- Quote ---Nope, sorry, i was misunderstandable. The FPHttpClient is declared inside a separate function which is not a part of the thread, but it is available in the entire unit and the thread calls this function.
--- End quote ---
Well you can change that if you like. If the function is called only from the thread, there is no point to declare it as a separate function. Since I know nothing about the internal structure of your program, I cannot give you more useful advice. I'm just shooting in the dark.
--- Quote ---Also, does FPC 3.1.1 work under OSX 10.6?
--- End quote ---
I see no reason why FPHttpClient.pp shouldn't work on OSX 10.6. Just give it a quick try.
TCH:
--- Quote from: GetMem on October 02, 2017, 02:17:23 pm ---
--- Quote ---Nope, sorry, i was misunderstandable. The FPHttpClient is declared inside a separate function which is not a part of the thread, but it is available in the entire unit and the thread calls this function.
--- End quote ---
Well you can change that if you like. If the function is called only from the thread, there is no point to declare it as a separate function. Since I know nothing about the internal structure of your program, I cannot give you more useful advice. I'm just shooting in the dark.
--- End quote ---
No, actually you are correct. The function was initially used by several other parts, but when i made the image loading threaded, then all other usage were removed. Thanks for pointing out. I think that will be the solution.
--- Quote from: GetMem on October 02, 2017, 02:17:23 pm ---
--- Quote ---Also, does FPC 3.1.1 work under OSX 10.6?
--- End quote ---
I see no reason why FPHttpClient.pp shouldn't work on OSX 10.6. Just give it a quick try.
--- End quote ---
Good. I'll try it under OSX 10.4 too, maybe i'll have luck. Actually i use the Synapse extension under OSX 10.4 and FPHttpClient under the rest of the OS-es, because OSX 10.4 does not have FPC 3, but maybe the FPHttpClient from 3.1 will work under OSX 10.4 too. If it does not work, then it means, that under OSX 10.4 the stuck is unsolvable. Or only available via killing the thread itself.
TCH:
Unfortunately, this method seems to be not working.
I have put the fphttpclient.pp 3.1.1 to my project dir. I have put the FPHTTPClient declaration into the public part of the thread. I made a FPHTTPClient.Get to an unreachable IP address, then i called the FPHTTPClient.Terminate from the main thread. No avail. It stucked.
Navigation
[0] Message Index
[#] Next page
[*] Previous page