public void insertTree(Trees.QuadTree.QuadTree<Map.Block> tree, Map.Rectangle location) { MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = String.Format("INSERT INTO `tiles` (`coord`, `image`) VALUES"); cmd.Connection = connection; bool first = true; for (int x = 0; x < tiles; x++) { for (int y = 0; y < tiles; y++) { Map.Block block = tree.Get(new Map.Rectangle(x, y, 1)); if (block != null) { if (!first) { cmd.CommandText += ","; } else { first = false; } cmd.CommandText += String.Format("({0}, {1})", getPolygonString(x + location.x, y + location.y, block.location.width), block.val); } } } mutex.WaitOne(); connection.Open(); cmd.ExecuteNonQuery(); connection.Close(); mutex.ReleaseMutex(); }