is it possible to use an infinite loop in a dll function without using a thread?
here's some example code:
BOOL WINAPI DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved) {
    switch (dwReason)
    {
    case DLL_PROCESS_ATTACH:
        DisableThreadLibraryCalls(hModule);
        GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_PIN, (LPCSTR)hModule, &hModule);
        CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)myfunction, 0, NULL, 0); //my current method
        myfunction(); //locks the program at runtime if i do it this way (just an example)
    case DLL_THREAD_ATTACH:
        break;
    case DLL_THREAD_DETACH:
        break;
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}
and here's an example of the function in the thread:
void myfunction() {
    //begin the infinite loop after 5 seconds
    Sleep(5000);
    for (;;) //set no condition for breaking the loop
    {
        Sleep(500); //this keeps the cpu from spiking
        //call my functions
        function1();
        function2();
        function3();
        function4();
    }
}
this code works well. i just wonder if there are alternatives. for example: can the function be written into the memory of the process? or called at a later time, instead of DLL_PROCESS_ATTACH?