// This will keep setting Jint's exit flag to true causing it to exit. // Leaves it in a Paused state. public void BreakPoller() { // ReturnStatement statement = new ReturnStatement((Expression)null); int count = 0; do { BreakEvent.WaitOne(); while (IsRunning) { if (count > 5) { count = 0; Shell.Write("Attempting to interrupt shell..."); EngineThread.Interrupt(); ConditionVariable.Interrupt(EngineThread); } Shell.Write("Attempting (" + count++ + ") to pause shell..."); Visitor.ForceBreak(); Thread.Sleep(1000); } } while (!IsClosing); }
public static void Interrupt(Thread t) { if (t != null) { int count = 0; t.Interrupt(); ConditionVariable.Interrupt(t); while (t.IsAlive) { try { Thread.Sleep(100); } catch (Exception) { } ++count; if (count > 30) { count = 0; Log.w(TAG, "Interrupted Thread not stopping:" + t.Name); } t.Interrupt(); ConditionVariable.Interrupt(t); } } }