Interrupt a thread

  • Thread starter Thread starter Hitesh Ashar
  • Start date Start date
H

Hitesh Ashar

I'm working with a CF project and I need to interrupt a thread.

Thread.Interrupt() is not supported in CF. Would anyone know if there
are any alternatives to do the same?

TIA
 
Interrupt it for what purpose? Generally, if you're just planning to exit a
thread, you need to write your code in such a way that conventional
interthread communication methods are used to notify the thread that it's
time to exit. For example, if the thread is managing communications with a
Socket and you want to exit the thread, you'd set an 'exit' flag and close
the socket from your controller thread. The thread would get some sort of
an exception because the socket was closed out from under it, it would then
check the exit flag and clean itself up.

Paul T.
 
Thanks Paul. I understand what you are saying.

However, I'm trying to migrate a full .NET library to CF and I am to
avoid any changes to the behavior of the code. The CF does have limited
overloads, however, there are several workarounds and I was wondering if
there was one to Thread.Interrupt.

BR,
Hitesh
 
No. In fact, there's no way to implement it without some knowledge of what
it's blocking on, so I think you're out of luck.

Paul T.
 
Back
Top