for (int i = 0; i < array.Count; i++) { Thread.Sleep(500); int minValueIndex = i; for (int j = i + 1; j < array.Count; j++) { if (array[j] < array[minValueIndex]) { minValueIndex = j; } } int temp = array[i]; array[i] = array[minValueIndex]; array[minValueIndex] = temp; chart1.Series[0].Points.DataBindXY(null, array); } For some reason, the code hangs and only after 10 seconds it builds the already sorted graph, that is, intermediate constructions are not visible. What could it be?
I guess that it affects Thread.Sleep() , but I don’t know how to do without it, because it is necessary to show the sorting step by step [ with intervals between drawing ] ...