How do I slow this fill algorithm so the user can see the images being filled gradually?

I have tried to use sleep() in conjunction with Redraw() but this causes the program to crash. The FLOOD_FINISHED message causes a call to Redraw()

void Redraw()
{
    InvalidateRect(g_hWnd, NULL, FALSE);
    UpdateWindow(g_hWnd);
}
void FloodFillUtil(CDIB32* scr, int xPos, int yPos)
{
    //using namespace std::chrono_literals;
    if (IsValid(scr, xPos, yPos))
    {
        //Redraw();
        scr->SetRGB(xPos, yPos, 255, 0, 0);
        FloodFillUtil(scr, xPos + 1, yPos);
        FloodFillUtil(scr, xPos - 1, yPos);
        FloodFillUtil(scr, xPos, yPos + 1);
        FloodFillUtil(scr, xPos, yPos - 1);
    }
    return;
}

void FloodFill(CDIB32* scr, CPoint& mid)
{
    int xPos = mid.x;
    int yPos = mid.y;
    FloodFillUtil(scr, xPos, yPos);
}
void SetupDoItThread()
{
    std::thread Worker(DoIt);
    Worker.join();
}


void SetupDogThreads(CPoint mid) 
{
    //Redraw();
    FloodFill(&m_screenDib, mid);
}

void DoIt()
{
    if (!m_done)
    {
        CPoint mid;
        std::vector<std::thread> threads;
        for (int i = 0; i < REZ * REZ; ++i)
        {
            CPoint mid;
            GetBlobMidPoint(i, mid);
            threads.push_back(std::thread(SetupDogThreads, mid));
        }
        for (auto& th : threads)
        {
            th.join();
        }
        ::PostMessage(g_hWnd, FLOOD_FINISHED, NULL, NULL);
        m_done = true;
    }
}
How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum