You need to simplify the problem - the code that you have makes no sense.
In reply to Re: detection in Loop condition by Marshall in thread detection in Loop condition by maha