/// <summary>
/// Do our best to kill a thread, passing state info
/// </summary>
/// <param name="thread">The thread to kill</param>
/// <param name="stateInfo">Info for the ThreadAbortException handler</param>
public static void Kill(Thread thread, object stateInfo)
{
try
{
if (stateInfo == null)
thread.Abort();
else
thread.Abort(stateInfo);
}
catch (ThreadStateException)
{
#if !NETCF
// Although obsolete, this use of Resume() takes care of
// the odd case where a ThreadStateException is received.
#pragma warning disable 0618,0612 // Thread.Resume has been deprecated
thread.Resume();
#pragma warning restore 0618,0612 // Thread.Resume has been deprecated
#endif
}
#if !NETCF
if ( (thread.ThreadState & ThreadState.WaitSleepJoin) != 0 )
thread.Interrupt();
#endif
}