"Nayan" <cn****@gmail.comwrote in message
news:11*********************@f1g2000cwa.googlegrou ps.com...
The scenario is that the external lib function is reading from remote
server. If the server is unable to respond, then my app (being
synchronous call), gets hung.
The lib function should time-out if the remote server is not able to respond, but it should
not let there caller hang indefinitely. So the only real solution is fix this code.
Killing the process is "okay" solution, though its not the fault of my
app.
JS has assumed correctly all the things.
I liked the idea of JS. I'll try to follow it.
>>>Simply aborting a single thread could leave other threads created by the library, or
resources unreclaimed etc.
True, but then its better to kill a thread than aborting the whole flow
of application. Threads can be managed if the dependency is low between
them.
No, it's not, because you can't abort a *managed* thread that is currently executing or
blocking in unmanaged code., all you can do is call Win32's "TerminateThread" API through
PInvoke and terminate the OS thread associated with the CLR thread, but doing this is
dangerous and should only be done when you know precisely what the thread was currently
doing (in unmanaged code), that is, you need at least an answer to the following question
(among others):
- what locks is the thread currently holding?
Most of the time (if not always), you can't answer this question, which leaves you with only
one option: kill the process.
Willy.
Willy.