/// <summary> /// Operation to perform the next differing traversal style /// </summary> /// <param name="cache"></param> /// <param name="link"></param> /// <returns></returns> private string nextDifferingDequeue(WebCache cache, string link) { if (cache.getLatestWebsite() == null) { return(link); } Random random = new Random(); // swap up until half nodes have been traversed int val = random.Next(webpageUrlQueue.size() / 2) + 1; Uri last = new Uri(cache.getLatestWebsite().getUrl()); Uri newest = null; bool foundDiffering = false; while (val > 0 && webpageUrlQueue.size() > 0 && foundDiffering == false) { val--; // swap to new site if (!webpageUrlQueue.tryRelease(out link)) { continue; } // create uri and check that the current dequeued link is different than current if (Uri.TryCreate(link, UriKind.Absolute, out newest)) { // if the domains/hosts differ, use it string newURL = newest.Authority; string oldURL = last.Authority; if (newURL.Equals(oldURL) == false) { foundDiffering = true; } } webpageUrlQueue.add(link); } return(link); }