dataGridView1.Rows[x1].Cells[y1].Style.BackColor = System.Drawing.Color.Red; System.Threading.Thread.Sleep(1000);
İ want to wait one second before
The Best way to wait without freezing your main thread is using the Task.Delay function.
So your code will look like this
var t = Task.Run(async delegate { dataGridView1.Rows[x1].Cells[y1].Style.BackColor = System.Drawing.Color.Red; dataGridView1.Refresh(); await Task.Delay(1000); });