public void Start() { Task getPagesThread; getPagesThread = Task.Run(() => GetPages()); Thread.Sleep(1); for (; AnalyzingPage < PageList.Count; AnalyzingPage++) { if (paused) { analizePause = true; } while (paused) { Thread.Sleep(1); } while (PageList[AnalyzingPage].content == null) { Thread.Sleep(5); } matrix[AnalyzingPage, AnalyzingPage] = 1; if (PageList[AnalyzingPage].statusCode != HttpStatusCode.OK) { continue; } var pageLinks = GetAllLinks(PageList[AnalyzingPage].content).ToArray(); for (int i = 0; i < pageLinks.Length; i++) { var item = pageLinks[i]; if (!PageList.AsParallel().Any(x => x.url == item)) { PageList.Add(new Page(item, PageList.Count)); var vector = Vector <double> .Build.Dense(matrix.RowCount, 0); matrix = matrix.InsertRow(matrix.RowCount, vector); vector = Vector <double> .Build.Dense(matrix.RowCount, 0); matrix = matrix.InsertColumn(matrix.ColumnCount, vector); } var index = PageList.FindIndex(x => x.url == item); matrix[index, AnalyzingPage] = 1; } var analizedPage = PageList[AnalyzingPage]; analizedPage.content = null; PageList[AnalyzingPage] = analizedPage; } IsDone = true; OnComplete(); }