Aborting a thread based on the Timer

  • Thread starter Thread starter siva sanks
  • Start date Start date
S

siva sanks

Hello,

I have a situation, in which, we would be calling the external
interfaces from our application. For some reason, the external
interface call doesnt produce any time outs and it hangs for ever. We
are thinking of spawning a call to the external interface in a thread,
and if it exceeds certain amount time, we would like to abort the
thread, so that our main execution wont keep on waiting for the
response from the external interface.

Is this is a good approach? Is there any better way tohandle the
same? Anycode sample to do the thread abort based on the timer class
would be greatly appreciated.

Thanks,
Shankar
 
Simply injecting an abort on another thread is no guarantee that the thread
will actually be aborted. If the thread is executing unmanaged code the
abort will not actually be delivered until the unmanaged code returns back
into the managed environment. However, if the thread is blocked on a managed
object then you should be able to abort it.
 
Back
Top