Hi everyone! I try do hot-reloading as casey in early episodes but I got problem. I do unload and load dll  when my project compiled but it doesn't work. If I add in main loop Sleep(~250) then it will be work. Also for me, my load and unload functions works fine but when I do changes in dll code nothing changes. If I will unload and load every frame it also will be work fine. Thanks for any help!
|  1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12 | internal void unloadGameCode(win32_game_code gameCode)
{
    if(gameCode.loadGameCodeDLL)
    {
        FreeLibrary(
                    gameCode.loadGameCodeDLL
                    );
    }
    gameCode.loadGameCodeDLL = 0;
    gameCode.isValid = false;
    gameCode.updateAndRender = game_update_and_render_stub;
}
 | 
|  1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 | internal win32_game_code loadGameCode(char *dllFileName)
{
    win32_game_code result = {};
    
    
    result.lastWriteTime = getLastWriteTime(dllFileName);
    s32 num = CopyFile(dllFileName,
                       "handmadeTemp.dll",
                       FALSE
                       );
    
    result.loadGameCodeDLL = LoadLibraryA("handmadeTemp.dll");
    
    if(result.loadGameCodeDLL)
    {
        result.updateAndRender = (game_update_and_render*)GetProcAddress(result.loadGameCodeDLL, "gameUpdateAndRender");
        
        if(result.updateAndRender)
        {
            result.isValid = true;
        }
    }
    
    if(!result.isValid)
    {
        result.updateAndRender = game_update_and_render_stub;
        result.loadGameCodeDLL = LoadLibraryA("handmade.dll"); 
    }
    
    return result;
}
 | 
|  | while(appIsRunning)
{
FILETIME DLLnewWriteTime = getLastWriteTime(sourceDLLname);
        
        if(CompareFileTime(&DLLnewWriteTime, &game.lastWriteTime) != 0 )
        {
            unloadGameCode(game);
            game = loadGameCode(sourceDLLname);
        }
}
 | 
This if statement works fine when I debug. Really thanks for any help!