public static QueryTask waitForQuery(ServiceHost host,String referrer,QueryTask query,Predicate<QueryTask> predicate,long waitIterationCount,long waitIterationSleep) throws Throwable {
  for (int i=0; i < waitIterationCount; i++) {
    QueryTask result=sendQueryAndWait(host,referrer,query);
    if (predicate.test(result)) {
      return result;
    }
    Thread.sleep(waitIterationSleep);
  }
  throw new RuntimeException("timeout waiting for query result.");
}

public static QueryTask waitForQuery ( ServiceHost host , String referrer , QueryTask query , Predicate < QueryTask > predicate , long waitIterationCount , long waitIterationSleep ) throws Throwable { for ( int i = 0 ; i < waitIterationCount ; i ++ ) { QueryTask result = sendQueryAndWait ( host , referrer , query ) ; if ( predicate . test ( result ) ) { return result ; } Thread . sleep ( waitIterationSleep ) ; } throw new RuntimeException ( "timeout waiting for query result." ) ; }
wait for a query to returns particular information .
