private static Move GetRandomCellToBePrint() { int k = Rand.Next(_globalCost); var res = new Move(); while (true) { Parallel.For(0, _height, i => Parallel.For(0, _width, j => { if (Expected[i][j] != Playground[i][j] && Expected[i][j] == '#') { lock (Lock) { k--; if (k == 0) { res.R = i; res.C = j; } } } })); if (!res.IsDefault()) { return res; } } }