Time Delay not working properly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JustJohn
    New Member
    • Apr 2014
    • 1

    Time Delay not working properly

    Ok, I have a chess board application. The application has 64 panels within a groupbox. These panels are identified with the expression CHessBoardPanel s{x,y). I am using this to change the background color of the panels. I want a small delay in between where the chessPanel.Back Ground changes to red and when the panels turn back to white.(approxim ately 1 to 2 second delay)
    I have tried the Sleep function but it basically locks the application up till the task have been complete

    Here is the code which I have tried:
    Code:
        for (int Row = 7; Row > 3; --Row)
                    {
                        chessBoardPanels[ Column ,Row].BackColor = Color.Red;
                        ++Column;
                        //Add text to Moves TextBox
                        MovesText.AppendFormat("WhtB               {0}                   {1}{2}"
                        , ColumnText,RowText,Environment.NewLine);
                        MovesTxt.Text = MovesText.ToString();
                        ++ColumnText;
                        --RowText;
                                           
                    }
                    //Start White Horizonal Drill 
                    Column = 0;
                    Thread.Sleep(5000);
                    for (int Row = 7; Row > 4; --Row)
                    {
                        chessBoardPanels[Column, Row].BackColor = Color.White;
                        ++Column;
                        //Add text to Moves TextBox
                        MovesText.AppendFormat("WhtB               {0}                   {1}{2}"
                        , ColumnText, RowText, Environment.NewLine);
                        MovesTxt.Text = MovesText.ToString();
                        ++ColumnText;
                        --RowText;
                      
                    }
    Last edited by Rabbit; Apr 8 '14, 03:25 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
Working...