private void Worker_doWork(object sender, DoWorkEventArgs e) { int edges = 0; foreach (var row in graph.AdjacencyList) { foreach (var item in row) { edges++; } } graph.EdgeCount = edges; backgroundWorker.ReportProgress(73); int n = graph.AdjacencyMatrix.GetLength(0); double oneStep = 28 / (double)n; for (int i = 0; i < n; i++) { var inOutEdg = CountInAndOutEdges(i); graph.AddVertice(i, inOutEdg.Item1, inOutEdg.Item2); if (i % 20 == 0) { backgroundWorker.ReportProgress(72 + (int)(oneStep * i)); } } backgroundWorker.ReportProgress(100); }